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
Patch new org creation condition on SAML account signup, enable users to toggle auth methods regardless of what org they are in
Tuan Dang22d89d791c1a
diff --git a/backend/src/services/auth/auth-signup-service.ts b/backend/src/services/auth/auth-signup-service.tsindex 6090a2129f..752d5d5639 100644--- a/backend/src/services/auth/auth-signup-service.ts+++ b/backend/src/services/auth/auth-signup-service.ts@@ -120,8 +120,10 @@ export const authSignupServiceFactory = ({throw new Error("Failed to complete account for complete user");}+ let organizationId;if (providerAuthToken) {- validateProviderAuthToken(providerAuthToken, user.email);+ const { orgId } = validateProviderAuthToken(providerAuthToken, user.email);+ organizationId = orgId;} else {validateSignUpAuthorization(authorization, user.id);}@@ -147,11 +149,7 @@ export const authSignupServiceFactory = ({return { info: us, key: userEncKey };});- const hasSamlEnabled = user?.authMethods?.some((authMethod) =>- [AuthMethod.OKTA_SAML, AuthMethod.AZURE_SAML, AuthMethod.JUMPCLOUD_SAML].includes(authMethod as AuthMethod)- );-- if (!hasSamlEnabled) {+ if (!organizationId) {await orgService.createOrganization(user.id, user.email, organizationName);}@@ -175,7 +173,8 @@ export const authSignupServiceFactory = ({authTokenType: AuthTokenType.ACCESS_TOKEN,userId: updateduser.info.id,tokenVersionId: tokenSession.id,- accessVersion: tokenSession.accessVersion+ accessVersion: tokenSession.accessVersion,+ organizationId},appCfg.AUTH_SECRET,{ expiresIn: appCfg.JWT_AUTH_LIFETIME }@@ -186,7 +185,8 @@ export const authSignupServiceFactory = ({authTokenType: AuthTokenType.REFRESH_TOKEN,userId: updateduser.info.id,tokenVersionId: tokenSession.id,- refreshVersion: tokenSession.refreshVersion+ refreshVersion: tokenSession.refreshVersion,+ organizationId},appCfg.AUTH_SECRET,{ expiresIn: appCfg.JWT_REFRESH_LIFETIME }diff --git a/backend/src/services/user/user-service.ts b/backend/src/services/user/user-service.tsindex b700869c2d..eebfd958f1 100644--- a/backend/src/services/user/user-service.ts+++ b/backend/src/services/user/user-service.ts@@ -30,15 +30,6 @@ export const userServiceFactory = ({ userDAL }: TUserServiceFactoryDep) => {const user = await userDAL.findById(userId);if (!user) throw new BadRequestError({ name: "Update auth methods" });- const hasSamlEnabled = user?.authMethods?.some((method) =>- [AuthMethod.OKTA_SAML, AuthMethod.AZURE_SAML, AuthMethod.JUMPCLOUD_SAML].includes(method as AuthMethod)- );- if (hasSamlEnabled)- throw new BadRequestError({- name: "Update auth method",- message: "Failed to update auth methods due to SAML SSO "- });-const updatedUser = await userDAL.updateById(userId, { authMethods });return updatedUser;};diff --git a/frontend/src/views/Settings/PersonalSettingsPage/AuthMethodSection/AuthMethodSection.tsx b/frontend/src/views/Settings/PersonalSettingsPage/AuthMethodSection/AuthMethodSection.tsxindex 73d266e2eb..5167bef17c 100644--- a/frontend/src/views/Settings/PersonalSettingsPage/AuthMethodSection/AuthMethodSection.tsx+++ b/frontend/src/views/Settings/PersonalSettingsPage/AuthMethodSection/AuthMethodSection.tsx@@ -25,8 +25,6 @@ const authMethodOpts: AuthMethodOption[] = [{ label: "GitLab", value: AuthMethod.GITLAB, icon: faGitlab }];-const samlProviders = [AuthMethod.OKTA_SAML, AuthMethod.JUMPCLOUD_SAML, AuthMethod.AZURE_SAML];-const schema = yup.object({authMethods: yup.array().required("Auth method is required")});@@ -56,17 +54,6 @@ export const AuthMethodSection = () => {}, [user]);const onAuthMethodToggle = async (value: boolean, authMethodOpt: AuthMethodOption) => {- const hasSamlEnabled = user.authMethods.some((authMethod: AuthMethod) =>- samlProviders.includes(authMethod)- );-- if (hasSamlEnabled) {- createNotification({- text: "SAML authentication can only be configured in your organization settings",- type: "error"- });- }-const newAuthMethods = value? [...authMethods, authMethodOpt.value]: authMethods.filter((auth) => auth !== authMethodOpt.value);