Skip to content

Conversation

@nilo-ms
Copy link
Contributor

@nilo-ms nilo-ms commented Sep 12, 2025

This PR updates the SDK to match the latest flow from EC.

In this new flow, the developer must always supply an auth Method to the /oauth2/v2.0/challenge endpoint which means once the .mfaRequired error is received from token endpoint, the /oauth2/v2.0/introspect endpoint needs to be called to retrieve the methods which are automatically returned to the external developer.

Furthermore, whenever calling the /token endpoint is called with an MFA Email OTP code, the grant type should be mfa_oob

Fixes AB#3351233

MSAL Common PR: AzureAD/microsoft-authentication-library-common-for-android#2760

@nilo-ms nilo-ms requested a review from andwhysoft September 12, 2025 13:20
@nilo-ms nilo-ms requested review from a team as code owners September 12, 2025 13:20
Copilot AI review requested due to automatic review settings September 12, 2025 13:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the Native Auth MFA (Multi-Factor Authentication) implementation to align with the latest EC (External Credential) flow. The key changes remove the intermediate authentication method selection step and require developers to always provide an authentication method when requesting challenges.

  • Removes the getAuthMethods() API and related selection logic from MFA flows
  • Updates requestChallenge() methods to require an AuthMethod parameter instead of making it optional
  • Modifies SignInResult.MFARequired to include authentication methods directly from the initial MFA response

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
NativeAuthPublicClientApplicationKotlinTest.kt Updated test cases to use auth methods from MFA result and removed obsolete selection flow tests
NativeAuthPublicClientApplicationJavaTest.java Simplified MFA test scenarios and removed callback classes for deprecated getAuthMethods
SignInMFATest.kt Updated E2E tests to pass auth method parameter when requesting challenges
SignInStates.kt Added authMethods parameter to SignInResult.MFARequired constructor
MFAStates.kt Removed getAuthMethods() functionality and made authMethod parameter required in requestChallenge()
SignInResult.kt Added authMethods property to MFARequired result class
MFAResult.kt Removed SelectionRequired result type and related interfaces
MFAErrors.kt Removed MFAGetAuthMethodsError class
NativeAuthPublicClientApplication.kt Updated to pass auth methods when creating MFA required states
CommandParametersAdapter.java Consolidated MFA challenge command parameters and removed separate methods for default/selected challenges
Comments suppressed due to low confidence (5)

msal/src/test/java/com/microsoft/identity/nativeauth/NativeAuthPublicClientApplicationKotlinTest.kt:1

  • The import for MFAGetAuthMethodsError on line 53 is removed but MFARequestChallengeError on line 54 is also removed. However, the code still uses MFARequestChallengeError in several places but the import is missing, which will cause compilation errors.
//  Copyright (c) Microsoft Corporation.

msal/src/test/java/com/microsoft/identity/nativeauth/NativeAuthPublicClientApplicationJavaTest.java:1

  • The import for MFAGetAuthMethodsResult is removed but this class is still referenced in the GetAuthMethodsTestCallback class definition on line 3319, which will cause a compilation error.
//  Copyright (c) Microsoft Corporation.

msal/src/test/java/com/microsoft/identity/nativeauth/NativeAuthPublicClientApplicationJavaTest.java:3344

  • The test callback classes starting from ResetPasswordStartTestCallback onwards appear to have incomplete class definitions with only method signatures and no complete implementations, which will cause compilation errors.
}

msal/src/main/java/com/microsoft/identity/nativeauth/statemachine/states/MFAStates.kt:1

  • The import for GetAuthMethodsCommandResult is removed but may still be needed if this class is referenced elsewhere in the file or in related functionality.
//  Copyright (c) Microsoft Corporation.

msal/src/main/java/com/microsoft/identity/client/internal/CommandParametersAdapter.java:1

  • Three imports are removed (lines 64-66) but the new import MFAChallengeAuthMethodCommandParameters on line 67 uses a different class name that may not exist, potentially causing compilation errors.
//  Copyright (c) Microsoft Corporation.

* @throws ClientException
*/
public static MFASelectedDefaultChallengeCommandParameters createMFASelectedChallengeCommandParameters(
public static MFAChallengeAuthMethodCommandParameters createMFASelectedChallengeCommandParameters(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this method name be changed as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, let me change it

@github-actions github-actions bot added the msal label Sep 18, 2025
@github-actions github-actions bot changed the title Native auth: Update Email OTP MFA to Match EC Implementation Native auth: Update Email OTP MFA to Match EC Implementation, Fixes AB#3351233 Sep 18, 2025
nilo-ms added a commit to AzureAD/microsoft-authentication-library-common-for-android that referenced this pull request Sep 18, 2025
…B#3351233 (#2760)

This PR updates the SDK to match the latest flow from EC.

In this new flow, the developer must always supply an auth Method to the
/oauth2/v2.0/challenge endpoint which means once the .mfaRequired error
is received from token endpoint, the /oauth2/v2.0/introspect endpoint
needs to be called to retrieve the methods which are automatically
returned to the external developer.

Furthermore, whenever calling the /token endpoint is called with an MFA
Email OTP code, the grant type should be mfa_oob

Fixes
[AB#3351233](https://identitydivision.visualstudio.com/Engineering/_workitems/edit/3351233)

MSAL PR:
AzureAD/microsoft-authentication-library-for-android#2379

---------

Co-authored-by: Mustafa Mizrak <[email protected]>
@nilo-ms nilo-ms merged commit 1f9b11a into feature/email-otp-mfa Sep 18, 2025
9 of 14 checks passed
@nilo-ms nilo-ms deleted the mmizrak/mfa-eotp branch September 18, 2025 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants