Skip to content

Commit 50deebc

Browse files
authored
Native auth: add new SDK error when auth method is blocked, Fixes AB#3313635 (#2384)
This PR adds a new SDK error with instructions when the auth method is blocked during MFA flow. MSAL Common PR: AzureAD/microsoft-authentication-library-common-for-android#2772 Fixes [AB#3313635](https://identitydivision.visualstudio.com/Engineering/_workitems/edit/3313635)
1 parent 4a1b012 commit 50deebc

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

msal/src/main/java/com/microsoft/identity/nativeauth/statemachine/errors/Error.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ internal class ErrorTypes {
8686
*/
8787
const val VERIFICATION_CONTACT_BLOCKED = "verification_contact_blocked"
8888

89+
/*
90+
* The AUTH_METHOD_BLOCKED value indicates that the server blocked the strong authentication method.
91+
* Try contacting customer support to seek assistance.
92+
*/
93+
const val AUTH_METHOD_BLOCKED = "auth_method_blocked"
94+
8995
/*
9096
* The INVALID_STATE value indicates a misconfigured or expired state, or an internal error
9197
* in state transitions. If this occurs, the flow should be restarted.

msal/src/main/java/com/microsoft/identity/nativeauth/statemachine/errors/MFAErrors.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ class MFARequestChallengeError(
2424
val subError: String? = null,
2525
override var exception: Exception? = null
2626
): MFARequiredResult, BrowserRequiredError, Error(errorType = errorType, error = error, errorMessage= errorMessage, correlationId = correlationId, errorCodes = errorCodes, exception = exception)
27+
{
28+
fun isAuthMethodBlocked(): Boolean = this.errorType == ErrorTypes.AUTH_METHOD_BLOCKED
29+
}
2730

2831
/**
2932
* MFA submit challenge error. The user should use the utility methods of this class

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class AwaitingMFAState(
9494
}
9595

9696
/**
97-
* Requests a challenge to be sent to the user's default authentication method; Kotlin coroutines variant.
97+
* Requests a challenge to be sent to the authentication method; Kotlin coroutines variant.
9898
*
9999
* <strong><u>Warning: this API is experimental. It may be changed in the future without notice. Do not use in production applications.</u></strong>
100100
* @return The result of the request challenge action.
@@ -165,6 +165,14 @@ class AwaitingMFAState(
165165
correlationId = result.correlationId
166166
)
167167
}
168+
is MFACommandResult.BlockedAuthMethod -> {
169+
MFARequestChallengeError(
170+
errorType = ErrorTypes.AUTH_METHOD_BLOCKED,
171+
error = result.error,
172+
errorMessage = result.errorDescription,
173+
correlationId = result.correlationId
174+
)
175+
}
168176
}
169177
} catch (e: Exception) {
170178
MFARequestChallengeError(
@@ -245,7 +253,7 @@ class MFARequiredState(
245253
}
246254

247255
/**
248-
* Requests a challenge to be sent to the user's default authentication method; Kotlin coroutines variant.
256+
* Requests a challenge to be sent to authentication method; Kotlin coroutines variant.
249257
*
250258
* <strong><u>Warning: this API is experimental. It may be changed in the future without notice. Do not use in production applications.</u></strong>
251259
* @param authMethod [com.microsoft.identity.nativeauth.AuthMethod] the authentication method used for the challenge operation.
@@ -318,6 +326,14 @@ class MFARequiredState(
318326
correlationId = result.correlationId
319327
)
320328
}
329+
is MFACommandResult.BlockedAuthMethod -> {
330+
MFARequestChallengeError(
331+
errorType = ErrorTypes.AUTH_METHOD_BLOCKED,
332+
error = result.error,
333+
errorMessage = result.errorDescription,
334+
correlationId = result.correlationId
335+
)
336+
}
321337
}
322338
} catch (e: Exception) {
323339
MFARequestChallengeError(

0 commit comments

Comments
 (0)