Skip to content

feat: resolved mfa error in token exchange mode#5803

Merged
maidul98 merged 2 commits intomainfrom
fix/patch-mfa
Mar 25, 2026
Merged

feat: resolved mfa error in token exchange mode#5803
maidul98 merged 2 commits intomainfrom
fix/patch-mfa

Conversation

@akhilmhdh
Copy link
Copy Markdown
Member

@akhilmhdh akhilmhdh commented Mar 25, 2026

Context

This PR fixes the MFA getting correctly redirected for the token exchange mode. The issue was the service change was not made in router, thus it was not getting redirect and using MFA token for the api calls.

Screenshots

Steps to verify the change

Type

  • Fix
  • Feature
  • Improvement
  • Breaking
  • Docs
  • Chore

Checklist

  • Title follows the conventional commit format: type(scope): short description (scope is optional, e.g., fix: prevent crash on sync or fix(api): handle null response).
  • Tested locally
  • Updated docs (if needed)
  • Updated CLAUDE.md files (if needed)
  • Read the contributing guide

@akhilmhdh akhilmhdh requested a review from maidul98 March 25, 2026 12:23
@maidul98
Copy link
Copy Markdown
Collaborator

maidul98 commented Mar 25, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

maidul98
maidul98 previously approved these changes Mar 25, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 25, 2026

Greptile Summary

This PR adds isMfaEnabled and mfaMethod fields to the /token-exchange SSO route response so that clients can correctly redirect to the MFA step when using the OAuth token exchange flow. The intent is correct, but the implementation contains a field-access bug that would break org-enforced MFA.

  • Bug: isMfaEnabled: data.user.isMfaEnabled reads the user's personal MFA flag from the database record (userEnc). The service's oauth2TokenExchange sets the top-level data.isMfaEnabled = true whenever either the org enforces MFA or the user has personal MFA enabled. When an organisation has enforceMfa = true but the individual user does not have personal MFA turned on, data.user.isMfaEnabled is false while data.isMfaEnabled is true — the client would skip MFA and misuse the issued MFA token as a regular access token.
  • The correct fix is to use data.isMfaEnabled (the top-level computed flag), not data.user.isMfaEnabled.
  • mfaMethod: data?.mfaMethod is correct — mfaMethod lives at the top level of the service return.

Confidence Score: 2/5

  • Not safe to merge as-is — org-enforced MFA silently breaks in the token-exchange flow.
  • The one-line fix has the correct structure, but reads the wrong field. Using data.user.isMfaEnabled instead of data.isMfaEnabled means that any organisation using enforced MFA (where the individual user has not personally enabled MFA) will receive isMfaEnabled: false even though the token returned is an MFA token, breaking that authentication path.
  • backend/src/server/routes/v1/sso-router.ts — line 632 must use data.isMfaEnabled instead of data.user.isMfaEnabled.

Important Files Changed

Filename Overview
backend/src/server/routes/v1/sso-router.ts Two new fields (isMfaEnabled, mfaMethod) are added to the token-exchange response, but isMfaEnabled reads from data.user.isMfaEnabled (user's personal DB flag) instead of the top-level data.isMfaEnabled computed by the service. This silently breaks org-enforced MFA when the user has no personal MFA setting.

Reviews (1): Last reviewed commit: "feat: resolved mfa error in token exchan..." | Re-trigger Greptile

@maidul98 maidul98 merged commit 22cf70d into main Mar 25, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants