Skip to content

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

fix: circular mfa issues

Tre Dubravac53f86f3090a
diff --git a/backend/src/server/routes/v1/sso-router.ts b/backend/src/server/routes/v1/sso-router.ts
index fdd9d868be..586c1c8537 100644
--- a/backend/src/server/routes/v1/sso-router.ts
+++ b/backend/src/server/routes/v1/sso-router.ts
@@ -615,15 +615,7 @@ export const registerSsoRouter = async (server: FastifyZodProvider) => {
{ skipDedup: true }
);
}
-
- if (data.isMfaEnabled) {
- return {
- token: data.token.access,
- isMfaEnabled: true,
- mfaMethod: data.mfaMethod
- } as const;
- }
-
+
if ([AuthMethod.GOOGLE, AuthMethod.GITHUB, AuthMethod.GITLAB].includes(data.decodedProviderToken.authMethod)) {
void res.setCookie("jid", data.token.refresh, {
httpOnly: true,
diff --git a/frontend/src/hooks/api/auth/types.ts b/frontend/src/hooks/api/auth/types.ts
index a06bc0be70..f30f0eacfd 100644
--- a/frontend/src/hooks/api/auth/types.ts
+++ b/frontend/src/hooks/api/auth/types.ts
@@ -76,7 +76,7 @@ export type Login2Res = {
export type OauthTokenExchangeRes = Login2Res & {
isMfaEnabled?: boolean;
- mfaMethod?: string;
+ mfaMethod?: MfaMethod;
};
export type LoginV3Res = {
diff --git a/frontend/src/pages/auth/LoginPage/components/PasswordStep/PasswordStep.tsx b/frontend/src/pages/auth/LoginPage/components/PasswordStep/PasswordStep.tsx
index 1a00776634..938a131715 100644
--- a/frontend/src/pages/auth/LoginPage/components/PasswordStep/PasswordStep.tsx
+++ b/frontend/src/pages/auth/LoginPage/components/PasswordStep/PasswordStep.tsx
@@ -65,10 +65,20 @@ export const PasswordStep = ({
if (oauthLogin.isMfaEnabled) {
SecurityClient.setMfaToken(oauthLogin.token);
if (oauthLogin.mfaMethod) {
- setRequiredMfaMethod(oauthLogin.mfaMethod as MfaMethod);
+ setRequiredMfaMethod(oauthLogin.mfaMethod);
}
toggleShowMfa.on();
- setMfaSuccessCallback(() => handleExchange);
+ // After MFA verification succeeds, the Mfa component sets the real auth token.
+ // Navigate to org selection as the post-login step (do NOT re-call handleExchange
+ // which would hit the token exchange endpoint and trigger MFA again in a loop).
+ setMfaSuccessCallback(() => async () => {
+ SecurityClient.setProviderAuthToken("");
+ if (callbackPort) {
+ navigateToSelectOrganization(callbackPort, isAdminLogin);
+ } else {
+ navigateToSelectOrganization(undefined, isAdminLogin);
+ }
+ });
setIsLoading(false);
return;
}