Repository navigation
Unify Native Auth V2 authentication method selection - #8899
Yongdi Wang (yongdiw) merged 16 commits into
Conversation
530213b to
2d419bf
Compare
| if (result.type === FLOW_MFA_REQUIRED_V2) { | ||
| return new CustomAuthResultV2( | ||
| new MFARequiredStateV2({ | ||
| new AuthMethodSelectionRequiredStateV2({ |
There was a problem hiding this comment.
Could we also expose this selection state when primary sign-in returns multiple supported methods? MSAL iOS dev lets the app choose in that case, but JS still calls selectSignInMethod() and automatically picks email or password before reaching this controller. As a result, the unified state is available for MFA here, but not for choosing the primary sign-in method. This behavior predates this PR; flagging it as a remaining iOS parity gap rather than a regression.
There was a problem hiding this comment.
Addressed in ea8ae5096. Primary sign-in now returns AuthMethodSelectionRequiredStateV2 whenever the server provides multiple supported Email, SMS, or Password methods, regardless of whether an initial password was supplied. A sole supported method is still selected automatically, and the initial password is not retained through multi-method selection. Unit and integration coverage was added for zero, one, and multiple supported methods.
|
|
||
| const expectedChallenge = | ||
| authenticationFactor === AuthenticationFactorV2.SINGLE_FACTOR | ||
| ? "an email or SMS code challenge for single-factor authentication" |
There was a problem hiding this comment.
Could we support a password-required result for primary sign-in selection, while keeping password reset restricted to email/SMS codes? MSAL iOS dev routes primary sign-in method selection to either code-required or password-required. This shared state still rejects password challenges, and RequestChallengeResultStateV2 cannot represent a password-required state. This restriction predates this PR and is not a failure in the currently wired reset/MFA paths; it is a remaining gap if this API is intended to cover primary sign-in selection too.
There was a problem hiding this comment.
Addressed in ea8ae5096. Selecting Password during primary single-factor sign-in now returns PasswordRequiredStateV2 through the sign-in transition handler. Password challenges remain unsupported for password reset and MFA. RequestChallengeResultV2 now represents the Password-required state, while CodeRequiredStateV2.resendCode() uses a dedicated ResendCodeResultV2 so its public return type remains code-only. Unit and integration coverage was added for both the Password and code-method paths.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: a64bca42-c756-4466-849e-4038c47bedb6
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: a64bca42-c756-4466-849e-4038c47bedb6
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: a64bca42-c756-4466-849e-4038c47bedb6
Stop carrying entry scopes and claims through continuation state or the authorization-code token request. Use the token response scope for cache processing and update V2 flow coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: a64bca42-c756-4466-849e-4038c47bedb6
Return method selection for multiple supported first-factor methods, map selected Password challenges to PasswordRequiredStateV2, and keep resend-code result typing narrow. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: a64bca42-c756-4466-849e-4038c47bedb6
2d419bf to
ea8ae50
Compare
…-method-selection
…-method-selection
…-method-selection
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: a64bca42-c756-4466-849e-4038c47bedb6
…-method-selection
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: a64bca42-c756-4466-849e-4038c47bedb6
…-method-selection
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: a64bca42-c756-4466-849e-4038c47bedb6
## Summary Unifies Native Auth V2 failures behind `AuthFlowErrorV2` while preserving the distinct service error contracts needed for classification and diagnostics. - Replaces flow-specific V2 error types across start, submit, resend, method-selection, and continuation results with one public error model and stable classifiers for invalid input, credentials, codes, passwords, usernames, missing or existing users, missing attributes, and browser fallback. - Normalizes both flat OAuth and nested HAL error payloads while keeping OAuth `subError` separate from HAL `innerErrorCode`; `web_redirect_required` remains an OAuth suberror used by `isBrowserRequired()`. - Exposes ordered, deduplicated `requiredAttributes` and `invalidAttributes` from attribute-validation details and safely ignores malformed external values. - Correctly distinguishes invalid credentials from password-policy failures and supports user-not-found, invalid-code, weak-password, existing-user, and password-targeted validation responses. - Preserves raw descriptions, error codes, correlation data, and flow scenario for diagnostics, documents browser fallback, and expands unit and integration coverage for the unified model and normalized API payloads. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: a64bca42-c756-4466-849e-4038c47bedb6
…-method-selection
## Summary Unifies Native Auth V2 failures behind `AuthFlowErrorV2` while preserving the distinct service error contracts needed for classification and diagnostics. - Replaces flow-specific V2 error types across start, submit, resend, method-selection, and continuation results with one public error model and stable classifiers for invalid input, credentials, codes, passwords, usernames, missing or existing users, missing attributes, and browser fallback. - Normalizes both flat OAuth and nested HAL error payloads while keeping OAuth `subError` separate from HAL `innerErrorCode`; `web_redirect_required` remains an OAuth suberror used by `isBrowserRequired()`. - Exposes ordered, deduplicated `requiredAttributes` and `invalidAttributes` from attribute-validation details and safely ignores malformed external values. - Correctly distinguishes invalid credentials from password-policy failures and supports user-not-found, invalid-code, weak-password, existing-user, and password-targeted validation responses. - Preserves raw descriptions, error codes, correlation data, and flow scenario for diagnostics, documents browser fallback, and expands unit and integration coverage for the unified model and normalized API payloads. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: a64bca42-c756-4466-849e-4038c47bedb6
Summary
Unifies Native Auth V2 authentication-method selection and makes challenge transitions result-driven.
AuthMethodSelectionRequiredStateV2.selectAuthMethod()and one public request-challenge result.PasswordRequiredStateV2, selected email/SMS code toCodeRequiredStateV2, and selected MFA code toMFAVerificationRequiredStateV2; unsupported combinations fail explicitly.