From 6c2ea938225179abefad0801a7d8500090d5c09a Mon Sep 17 00:00:00 2001 From: Carlos Monastyrski Date: Thu, 4 Sep 2025 17:43:40 -0300 Subject: [PATCH] Improve handleSelectOrganization logic for SSO enforcement --- .../auth/SelectOrgPage/SelectOrgSection.tsx | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/frontend/src/pages/auth/SelectOrgPage/SelectOrgSection.tsx b/frontend/src/pages/auth/SelectOrgPage/SelectOrgSection.tsx index aeb38a182..4dd0bbe24 100644 --- a/frontend/src/pages/auth/SelectOrgPage/SelectOrgSection.tsx +++ b/frontend/src/pages/auth/SelectOrgPage/SelectOrgSection.tsx @@ -88,29 +88,24 @@ export const SelectOrganizationSection = () => { // org has an org-level auth method enabled (e.g. SAML) // -> logout + redirect to SAML SSO let url = ""; - if (organization.orgAuthMethod === AuthMethod.OIDC) { + if (organization.googleSsoAuthEnforced) { + if (authToken.authMethod !== AuthMethod.GOOGLE) { + url = `/api/v1/sso/redirect/google?org_slug=${organization.slug}`; + + if (callbackPort) { + url += `&callback_port=${callbackPort}`; + } + } + } else if (organization.orgAuthMethod === AuthMethod.OIDC) { url = `/api/v1/sso/oidc/login?orgSlug=${organization.slug}${ callbackPort ? `&callbackPort=${callbackPort}` : "" }`; - } else if ( - organization.orgAuthMethod === AuthMethod.SAML && - // if google sso is enforced, we don't want to redirect to saml - !organization.googleSsoAuthEnforced - ) { + } else if (organization.orgAuthMethod === AuthMethod.SAML) { url = `/api/v1/sso/redirect/saml2/organizations/${organization.slug}`; if (callbackPort) { url += `?callback_port=${callbackPort}`; } - } else if ( - organization.googleSsoAuthEnforced && - authToken.authMethod !== AuthMethod.GOOGLE - ) { - url = `/api/v1/sso/redirect/google?org_slug=${organization.slug}`; - - if (callbackPort) { - url += `&callback_port=${callbackPort}`; - } } // we are conditionally checking if the url is set because it may not be set if google SSO is enforced, but the user is already logged in with google SSO