Skip to content

Commit fed47bb

Browse files
committed
Added new error type for thumbprint mismatch scenario
1 parent 0b0826b commit fed47bb

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

auth0/src/main/java/com/auth0/android/authentication/storage/BaseCredentialsManager.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ public abstract class BaseCredentialsManager internal constructor(
238238

239239
if (storedThumbprint != null) {
240240
if (currentThumbprint != storedThumbprint) {
241-
Log.w(this::class.java.simpleName, "DPoP key thumbprint mismatch. Clearing stale credentials.")
241+
Log.w(this::class.java.simpleName, "DPoP key thumbprint mismatch. The key pair has changed since credentials were saved. Clearing stale credentials.")
242242
clearCredentials()
243-
return CredentialsManagerException(CredentialsManagerException.Code.DPOP_KEY_MISSING)
243+
return CredentialsManagerException(CredentialsManagerException.Code.DPOP_KEY_MISMATCH)
244244
}
245245
} else if (currentThumbprint != null) {
246246
// Migration: existing DPoP user upgraded — no thumbprint stored yet.

auth0/src/main/java/com/auth0/android/authentication/storage/CredentialsManagerException.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ public class CredentialsManagerException :
4949
SSO_EXCHANGE_FAILED,
5050
MFA_REQUIRED,
5151
DPOP_KEY_MISSING,
52+
DPOP_KEY_MISMATCH,
5253
DPOP_NOT_CONFIGURED,
5354
UNKNOWN_ERROR
5455
}
@@ -163,6 +164,8 @@ public class CredentialsManagerException :
163164

164165
public val DPOP_KEY_MISSING: CredentialsManagerException =
165166
CredentialsManagerException(Code.DPOP_KEY_MISSING)
167+
public val DPOP_KEY_MISMATCH: CredentialsManagerException =
168+
CredentialsManagerException(Code.DPOP_KEY_MISMATCH)
166169
public val DPOP_NOT_CONFIGURED: CredentialsManagerException =
167170
CredentialsManagerException(Code.DPOP_NOT_CONFIGURED)
168171

@@ -215,6 +218,7 @@ public class CredentialsManagerException :
215218
Code.SSO_EXCHANGE_FAILED ->"The exchange of the refresh token for SSO credentials failed."
216219
Code.MFA_REQUIRED -> "Multi-factor authentication is required to complete the credential renewal."
217220
Code.DPOP_KEY_MISSING -> "The stored credentials are DPoP-bound but the DPoP key pair is no longer available in the Android KeyStore. Re-authentication is required."
221+
Code.DPOP_KEY_MISMATCH -> "The stored credentials are DPoP-bound but the current DPoP key pair does not match the one used when credentials were saved. Re-authentication is required."
218222
Code.DPOP_NOT_CONFIGURED -> "The stored credentials are DPoP-bound but the AuthenticationAPIClient used by this credentials manager was not configured with useDPoP(context). Call AuthenticationAPIClient(auth0).useDPoP(context) and pass the configured client to the credentials manager."
219223
Code.UNKNOWN_ERROR -> "An unknown error has occurred while fetching the token. Please check the error cause for more details."
220224
}

0 commit comments

Comments
 (0)