Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
Update redirect to org after SSO
Tuan Dang51b788cc5b60
diff --git a/backend/src/utils/authn/passport/saml.ts b/backend/src/utils/authn/passport/saml.tsindex f02e78be1a..d6f22e6726 100644--- a/backend/src/utils/authn/passport/saml.ts+++ b/backend/src/utils/authn/passport/saml.ts@@ -75,7 +75,7 @@ export const initializeSamlStrategy = async () => {const organization = await Organization.findById(req.ssoConfig.organization);if (!organization) return done(OrganizationNotFoundError());-+const email = profile.email;const firstName = profile.firstName;const lastName = profile.lastName;@@ -154,6 +154,7 @@ export const initializeSamlStrategy = async () => {firstName,lastName,organizationName: organization?.name,+ organizationId: organization?._id,authMethod: req.ssoConfig.authProvider,isUserCompleted,...(req.body.RelayState ? {diff --git a/frontend/src/views/Login/Login.utils.tsx b/frontend/src/views/Login/Login.utils.tsxindex c8bf2f6c12..fd3a2df0bd 100644--- a/frontend/src/views/Login/Login.utils.tsx+++ b/frontend/src/views/Login/Login.utils.tsx@@ -2,9 +2,15 @@ import { NextRouter } from "next/router";import { fetchOrganizations } from "@app/hooks/api/organization/queries";-export const navigateUserToOrg = async (router: NextRouter) => {+export const navigateUserToOrg = async (router: NextRouter, organizationId?: string) => {const userOrgs = await fetchOrganizations();+ if (organizationId) {+ localStorage.setItem("orgData.id", organizationId);+ router.push(`/org/${organizationId}/overview`);+ return;+ }+if (userOrgs.length > 0) {// user is part of at least 1 orgconst userOrg = userOrgs[0] && userOrgs[0]._id;diff --git a/frontend/src/views/Login/components/MFAStep/MFAStep.tsx b/frontend/src/views/Login/components/MFAStep/MFAStep.tsxindex df8e7b0d7a..89e6c2f709 100644--- a/frontend/src/views/Login/components/MFAStep/MFAStep.tsx+++ b/frontend/src/views/Login/components/MFAStep/MFAStep.tsx@@ -78,6 +78,7 @@ export const MFAStep = ({let isLinkingRequired: undefined | boolean;let callbackPort: undefined | string;let authMethod: undefined | AuthMethod;+ let organizationId: undefined | string;if (providerAuthToken) {const decodedToken = jwt_decode(providerAuthToken) as any;@@ -85,6 +86,7 @@ export const MFAStep = ({isLinkingRequired = decodedToken.isLinkingRequired;callbackPort = decodedToken.callbackPort;authMethod = decodedToken.authMethod;+ organizationId = decodedToken?.organizationId;}if (mfaCode.length !== 6) {@@ -142,7 +144,7 @@ export const MFAStep = ({});}- await navigateUserToOrg(router);+ await navigateUserToOrg(router, organizationId);} else {createNotification({text: "Failed to log in",diff --git a/frontend/src/views/Login/components/PasswordStep/PasswordStep.tsx b/frontend/src/views/Login/components/PasswordStep/PasswordStep.tsxindex b0994a0aae..6924da3e75 100644--- a/frontend/src/views/Login/components/PasswordStep/PasswordStep.tsx+++ b/frontend/src/views/Login/components/PasswordStep/PasswordStep.tsx@@ -38,7 +38,8 @@ export const PasswordStep = ({const {callbackPort,isLinkingRequired,- authMethod+ authMethod,+ organizationId} = jwt_decode(providerAuthToken) as any;const handleLogin = async (e:React.FormEvent) => {@@ -107,7 +108,7 @@ export const PasswordStep = ({});}- await navigateUserToOrg(router);+ await navigateUserToOrg(router, organizationId);}}} catch (err) {diff --git a/frontend/src/views/Signup/SignupSSO.tsx b/frontend/src/views/Signup/SignupSSO.tsxindex 0946076a48..afee2d0b52 100644--- a/frontend/src/views/Signup/SignupSSO.tsx+++ b/frontend/src/views/Signup/SignupSSO.tsx@@ -19,7 +19,7 @@ export const SignupSSO = ({email,organizationName,firstName,- lastName+ lastName,} = jwt_decode(providerAuthToken) as any;const renderView = () => {