Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

refactor(auth): extract SAML auth methods into shared constant

Igor Correaf573894894cc
diff --git a/frontend/src/hooks/api/users/types.ts b/frontend/src/hooks/api/users/types.ts
index 7f9105852d..9bf0516253 100644
--- a/frontend/src/hooks/api/users/types.ts
+++ b/frontend/src/hooks/api/users/types.ts
@@ -1,6 +1,15 @@
import { MfaMethod } from "../auth/types";
import { ProjectType, ProjectUserMembershipTemporaryMode } from "../projects/types";
+export const SAML_AUTH_METHODS = [
+ "okta-saml",
+ "azure-saml",
+ "jumpcloud-saml",
+ "keycloak-saml",
+ "google-saml",
+ "saml"
+] as const;
+
export enum AuthMethod {
EMAIL = "email",
GOOGLE = "google",
diff --git a/frontend/src/pages/auth/SelectOrgPage/SelectOrgSection.tsx b/frontend/src/pages/auth/SelectOrgPage/SelectOrgSection.tsx
index acc0df0c9c..62d8daa3f1 100644
--- a/frontend/src/pages/auth/SelectOrgPage/SelectOrgSection.tsx
+++ b/frontend/src/pages/auth/SelectOrgPage/SelectOrgSection.tsx
@@ -26,7 +26,7 @@ import {
import { MfaMethod, UserAgentType } from "@app/hooks/api/auth/types";
import { getAuthToken, isLoggedIn } from "@app/hooks/api/reactQuery";
import { Organization } from "@app/hooks/api/types";
-import { AuthMethod } from "@app/hooks/api/users/types";
+import { AuthMethod, SAML_AUTH_METHODS } from "@app/hooks/api/users/types";
import { navigateUserToOrg } from "../LoginPage/Login.utils";
@@ -142,15 +142,7 @@ export const SelectOrganizationSection = () => {
callbackPort ? `&callbackPort=${callbackPort}` : ""
}`;
} else if (organization.orgAuthMethod === AuthMethod.SAML) {
- const samlAuthMethods = [
- AuthMethod.SAML,
- AuthMethod.OKTA_SAML,
- AuthMethod.AZURE_SAML,
- AuthMethod.JUMPCLOUD_SAML,
- AuthMethod.KEYCLOAK_SAML,
- AuthMethod.GOOGLE_SAML
- ];
- if (!samlAuthMethods.includes(authToken.authMethod)) {
+ if (!SAML_AUTH_METHODS.includes(authToken.authMethod as (typeof SAML_AUTH_METHODS)[number])) {
url = `/api/v1/sso/redirect/saml2/organizations/${organization.slug}`;
if (callbackPort) {
url += `?callback_port=${callbackPort}`;