-
Notifications
You must be signed in to change notification settings - Fork 82
Add support for OOB multi-factor authentication #632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -403,14 +431,16 @@ public void onDatabaseAuthenticationRequest(@NonNull DatabaseLoginEvent event) { | |||
AuthenticationAPIClient apiClient = options.getAuthenticationAPIClient(); | |||
AuthenticationRequest request; | |||
Map<String, String> parameters = new HashMap<>(options.getAuthenticationParameters()); | |||
if (TextUtils.isEmpty(event.getMFAToken()) || TextUtils.isEmpty(event.getVerificationCode())) { | |||
if (TextUtils.isEmpty(event.getMultifactorToken())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if there's no mfa_token
, then log in normally
if (!TextUtils.isEmpty(event.getVerificationCode())) { | ||
parameters.put(KEY_VERIFICATION_CODE, event.getVerificationCode()); | ||
} | ||
} else if (MFA_CHALLENGE_TYPE_OOB.equals(lastDatabaseLogin.getMultifactorChallengeType())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if there's an mfa_token
and also the challenge type is "oob", complete the verification using OOB
} else { | ||
request = apiClient.loginWithOTP(event.getMFAToken(), event.getVerificationCode()); | ||
// otp multi-factor authentication | ||
request = apiClient.loginWithOTP(event.getMultifactorToken(), event.getMultifactorOTP()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise, complete the verification using the OTP
}); | ||
if (error.isMultifactorRequired()) { | ||
String mfaToken = (String) error.getValue(KEY_MFA_TOKEN); | ||
requestMFAChallenge(mfaToken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this logic was moved into a separate function requestMFAChallenge
@@ -440,50 +521,6 @@ public void shouldCallOIDCDatabaseSignInWithCustomAudience() { | |||
assertThat(reqParams, hasEntry("extra", "value")); | |||
} | |||
|
|||
@Test | |||
public void shouldCallLegacyDatabaseSignInWithUsername() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
legacy tests for /oauth/ro MFA, removed
Changes
Whenever an
mfa_required
error is received from the server, and before showing the "MFA prompt" screen, the SDK will attempt to send an MFA challenge request to the registered OOB factor. If the user doesn't have any, the request will fail but the user will still be able to complete the authentication using the OTP generated from their favorite app.This PR also bumps the dependencies and commits the line-endings setting so every IDE will pick up.
References
See
SDK-2658
.Videos showing the usage
MFA with SMS (OOB)
MFA-SMS-Success.mp4
MFA with OTP (fallback, always available)
MFA-OTP.mp4
Testing
Some tests regarding legacy use cases, those related to
/oauth/ro
MFA, were removed. Functionality is unaffected.This change adds unit test coverage
This change adds integration/UI test coverage
This change has been tested on the latest version of the platform/language or why not
Checklist
I have read the Auth0 general contribution guidelines
I have read the Auth0 Code of Conduct
All existing and new tests complete without errors
The correct base branch is being used