fix: preserve extra login options in MFA flows - #403
Open
boomshakar wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Jira Link
N/A
Description
enableMFA()andmanageMFA()currently replace the caller'sextraLoginOptionswith an object containing only the authenticated user'slogin_hint.This was reproduced in the Manage MFA custom-JWT flow, where caller-provided
values such as
client_idand a freshid_tokenare required to continue thehosted authentication step. Source review found the same parameter-loss
behavior in
enableMFA().This change merges caller-provided
extraLoginOptionsbefore settinglogin_hintfrom authenticated session state in both MFA methods. It:login_hinttakes precedence;extraLoginOptionsis omitted;login()or any public API.The change is backward-compatible because callers without extra login options
receive the same payload as before.
Security
Tests use synthetic identifiers and tokens only. The change does not log or
otherwise expose credentials; it preserves caller-supplied values within the
existing MFA auth-request payload path.
How has this been tested?
npm test— 17 test files and 433 tests passed.npm run lint— passed with no errors.npm run build— ESM and CJS builds completed successfully.enableMFA()andmanageMFA():client_idandid_token;login_hintprecedence;extraLoginOptions;Screenshots (if appropriate)
N/A
Types of changes
Checklist
Note
Medium Risk
Changes how MFA auth-start payloads assemble login options in security-sensitive flows, though behavior is backward compatible and covered by new tests.
Overview
Fixes a bug where
enableMFA()andmanageMFA()builtextraLoginOptionswith only the sessionlogin_hint, dropping caller-supplied values (e.g. custom-JWTclient_idandid_token) needed for Manage MFA.Both methods now spread
params.extraLoginOptionsfirst, then setlogin_hintfrom the authenticated user so session identity still wins over a caller-provided hint. OmittedextraLoginOptionsbehaves as before.Adds
test/auth.test.tswith eight Vitest cases covering preservation of JWT fields,login_hintprecedence, omitted options, and unchanged MFA payload/flow behavior for both APIs.Reviewed by Cursor Bugbot for commit 9a0396e. Bugbot is set up for automated code reviews on this repo. Configure here.