Skip to content

Commit

Permalink
Add support for tenant session_cookie property (#88)
Browse files Browse the repository at this point in the history
* Adding session cookie configuration to tenant

* Adding comment

* Adding tests

* Commenting exported struct

* Adding period

Co-authored-by: Will Vedder <[email protected]>
  • Loading branch information
willvedd and Will Vedder authored Jul 11, 2022
1 parent bcd755a commit 012e5fc
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 3 deletions.
21 changes: 21 additions & 0 deletions management/management.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions management/management.gen_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions management/tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ type Tenant struct {

// Supported locales for the UI
EnabledLocales []interface{} `json:"enabled_locales,omitempty"`

SessionCookie *TenantSessionCookie `json:"session_cookie,omitempty"`
}

// MarshalJSON is a custom serializer for the Tenant type.
Expand Down Expand Up @@ -335,6 +337,11 @@ type TenantDeviceFlow struct {
Mask *string `json:"mask,omitempty"`
}

// TenantSessionCookie manages behavior of the tenant's session cookie, accepts either 'persistent' or 'non-persistent'.
type TenantSessionCookie struct {
Mode *string `json:"mode,omitempty"`
}

// TenantManager manages Auth0 Tenant resources.
type TenantManager struct {
*Management
Expand Down
4 changes: 4 additions & 0 deletions management/tenant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ func TestTenantManager(t *testing.T) {
DefaultRedirectionURI: auth0.String("https://example.com/login"),
SessionLifetime: auth0.Float64(1080),
IdleSessionLifetime: auth0.Float64(720.2), // will be rounded off
SessionCookie: &TenantSessionCookie{
Mode: auth0.String("non-persistent"),
},
}
err = m.Tenant.Update(newTenantSettings)
assert.NoError(t, err)
Expand All @@ -43,6 +46,7 @@ func TestTenantManager(t *testing.T) {
assert.Equal(t, newTenantSettings.GetSessionLifetime(), actualTenantSettings.GetSessionLifetime())
assert.Equal(t, newTenantSettings.GetSupportEmail(), actualTenantSettings.GetSupportEmail())
assert.Equal(t, newTenantSettings.GetSupportURL(), actualTenantSettings.GetSupportURL())
assert.Equal(t, newTenantSettings.SessionCookie.GetMode(), actualTenantSettings.SessionCookie.GetMode())
}

func TestTenant_MarshalJSON(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions management/testdata/recordings/TestTenantManager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interactions:
duration: 1ms
- request:
body: |
{"friendly_name":"My Example Tenant","support_email":"[email protected]","support_url":"https://support.example.com","session_lifetime":1080,"idle_session_lifetime":720,"default_redirection_uri":"https://example.com/login"}
{"friendly_name":"My Example Tenant","support_email":"[email protected]","support_url":"https://support.example.com","session_lifetime":1080,"idle_session_lifetime":720,"default_redirection_uri":"https://example.com/login","session_cookie":{"mode":"non-persistent"}}
form: {}
headers:
Content-Type:
Expand All @@ -38,7 +38,7 @@ interactions:
body: '{"allowed_logout_urls":["https://mycompany.org/logoutCallback"],"change_password":{"enabled":true,"html":"<html>Change
Password</html>"},"default_redirection_uri":"https://example.com/login","enabled_locales":["de","fr"],"error_page":{"html":"<html>Error
Page</html>","url":"https://mycompany.org/error","show_log_link":false},"flags":{"allow_changing_enable_sso":false,"cannot_change_enforce_client_authentication_on_passwordless_start":true,"change_pwd_flow_v1":false,"disable_impersonation":true,"enable_apis_section":false,"enable_client_connections":true,"enable_custom_domain_in_emails":false,"enable_dynamic_client_registration":false,"enable_legacy_logs_search_v2":false,"enable_public_signup_user_exists_error":true,"enable_sso":true,"enforce_client_authentication_on_passwordless_start":true,"new_universal_login_experience_enabled":false,"universal_login":false,"use_scope_descriptions_for_consent":false,"revoke_refresh_token_grant":false,"disable_clickjack_protection_headers":false,"enable_pipeline2":false},"friendly_name":"My
Example Tenant","guardian_mfa_page":{"enabled":true,"html":"<html>MFA</html>"},"idle_session_lifetime":720,"picture_url":"https://mycompany.org/logo.png","sandbox_version":"12","session_lifetime":1080,"support_email":"[email protected]","support_url":"https://support.example.com","universal_login":{"colors":{"primary":"#ea5323","page_background":{"type":"linear-gradient","start":"#000000","end":"#ffffff","angle_deg":35}}}}'
Example Tenant","guardian_mfa_page":{"enabled":true,"html":"<html>MFA</html>"},"idle_session_lifetime":720,"picture_url":"https://mycompany.org/logo.png","sandbox_version":"12","session_cookie":{"mode":"non-persistent"},"session_lifetime":1080,"support_email":"[email protected]","support_url":"https://support.example.com","universal_login":{"colors":{"primary":"#ea5323","page_background":{"type":"linear-gradient","start":"#000000","end":"#ffffff","angle_deg":35}}}}'
headers:
Content-Type:
- application/json; charset=utf-8
Expand All @@ -60,7 +60,7 @@ interactions:
body: '{"allowed_logout_urls":["https://mycompany.org/logoutCallback"],"change_password":{"enabled":true,"html":"<html>Change
Password</html>"},"default_redirection_uri":"https://example.com/login","enabled_locales":["de","fr"],"error_page":{"html":"<html>Error
Page</html>","url":"https://mycompany.org/error","show_log_link":false},"flags":{"allow_changing_enable_sso":false,"change_pwd_flow_v1":false,"disable_impersonation":true,"enable_apis_section":false,"enable_client_connections":true,"enable_custom_domain_in_emails":false,"enable_dynamic_client_registration":false,"enable_legacy_logs_search_v2":false,"enable_public_signup_user_exists_error":true,"enable_sso":true,"new_universal_login_experience_enabled":false,"universal_login":false,"use_scope_descriptions_for_consent":false,"revoke_refresh_token_grant":false,"disable_clickjack_protection_headers":false,"enable_pipeline2":false},"friendly_name":"My
Example Tenant","guardian_mfa_page":{"enabled":true,"html":"<html>MFA</html>"},"idle_session_lifetime":720,"picture_url":"https://mycompany.org/logo.png","sandbox_version":"12","session_lifetime":1080,"support_email":"[email protected]","support_url":"https://support.example.com","universal_login":{"colors":{"primary":"#ea5323","page_background":{"type":"linear-gradient","start":"#000000","end":"#ffffff","angle_deg":35}}},"sandbox_versions_available":["12"]}'
Example Tenant","guardian_mfa_page":{"enabled":true,"html":"<html>MFA</html>"},"idle_session_lifetime":720,"picture_url":"https://mycompany.org/logo.png","sandbox_version":"12","session_cookie":{"mode":"non-persistent"},"session_lifetime":1080,"support_email":"[email protected]","support_url":"https://support.example.com","universal_login":{"colors":{"primary":"#ea5323","page_background":{"type":"linear-gradient","start":"#000000","end":"#ffffff","angle_deg":35}}},"sandbox_versions_available":["12"]}'
headers:
Content-Type:
- application/json; charset=utf-8
Expand Down

0 comments on commit 012e5fc

Please sign in to comment.