Repository: cloudflare/cloudflare-go
Pull request #2455 (2024-06-10 21:36:28)

AUTH-6181 Add Access OIDC SaaS Application access token lifetime
## Description
https://developers.cloudflare.com/api/operations/access-applications-add-an-application

## Has your change been tested?

unit tests

## Screenshots (if appropriate):

## Types of changes

What sort of change does your code introduce/modify?

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Checklist:

- [ ] My code follows the code style of this project.
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
- [ ] This change is using publicly documented in [cloudflare/api-schemas](https://github.com/cloudflare/api-schemas) 
      and relies on stable APIs.

[1]: https://help.github.com/articles/closing-issues-using-keywords/



Patch:
diff --git a/.changelog/2455.txt b/.changelog/2455.txt
new file mode 100644
index 000000000..a3908aeb0
--- /dev/null
+++ b/.changelog/2455.txt
@@ -0,0 +1,3 @@
+```release-note:enhancement
+access_application: Add support for SaaS OIDC Access Token Lifetime
+```
diff --git a/access_application.go b/access_application.go
index 315ccb027..bdeaf79cd 100644
--- a/access_application.go
+++ b/access_application.go
@@ -246,6 +246,7 @@ type SaasApplication struct {
 	AllowPKCEWithoutClientSecret *bool                                      `json:"allow_pkce_without_client_secret,omitempty"`
 	RefreshTokenOptions          *RefreshTokenOptions                       `json:"refresh_token_options,omitempty"`
 	HybridAndImplicitOptions     *AccessApplicationHybridAndImplicitOptions `json:"hybrid_and_implicit_options,omitempty"`
+	AccessTokenLifetime          string                                     `json:"access_token_lifetime,omitempty"`
 }
 
 type AccessAppLauncherCustomization struct {


Test patch:
diff --git a/access_application_test.go b/access_application_test.go
index 714dde568..178386395 100644
--- a/access_application_test.go
+++ b/access_application_test.go
@@ -1130,7 +1130,8 @@ func TestCreateOIDCSaasAccessApplications(t *testing.T) {
 					"hybrid_and_implicit_options": {
 						"return_id_token_from_authorization_endpoint": true,
 						"return_access_token_from_authorization_endpoint": true
-					}
+					},
+					"access_token_lifetime": "1m"
 				}
 			}
 		}
@@ -1177,6 +1178,7 @@ func TestCreateOIDCSaasAccessApplications(t *testing.T) {
 				ReturnIDTokenFromAuthorizationEndpoint:     BoolPtr(true),
 				ReturnAccessTokenFromAuthorizationEndpoint: BoolPtr(true),
 			},
+			AccessTokenLifetime: "1m",
 		},
 		CreatedAt:                &createdAt,
 		UpdatedAt:                &updatedAt,
@@ -1207,6 +1209,7 @@ func TestCreateOIDCSaasAccessApplications(t *testing.T) {
 				ReturnIDTokenFromAuthorizationEndpoint:     BoolPtr(true),
 				ReturnAccessTokenFromAuthorizationEndpoint: BoolPtr(true),
 			},
+			AccessTokenLifetime: "1m",
 		},
 		SessionDuration: "24h",
 	})
@@ -1238,6 +1241,7 @@ func TestCreateOIDCSaasAccessApplications(t *testing.T) {
 				ReturnIDTokenFromAuthorizationEndpoint:     BoolPtr(true),
 				ReturnAccessTokenFromAuthorizationEndpoint: BoolPtr(true),
 			},
+			AccessTokenLifetime: "1m",
 		},
 		SessionDuration: "24h",
 	})