Skip to content

Commit ee5b61c

Browse files
committed
Add case insensitive check
1 parent bf4abd4 commit ee5b61c

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

auth0/src/main/java/com/auth0/android/provider/IdTokenVerifier.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ internal class IdTokenVerifier {
7373
if (TextUtils.isEmpty(orgNameClaim)) {
7474
throw OrgNameClaimMissingException()
7575
}
76-
if (organizationInput != orgNameClaim) {
76+
if (!organizationInput.equals(orgNameClaim, true)) {
7777
throw OrgNameClaimMismatchException(organizationInput, orgNameClaim)
7878
}
7979
}

auth0/src/test/java/com/auth0/android/provider/IdTokenVerifierTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,25 @@ public void shouldFailWhenOrganizationNameClaimIsRequiredAndHasUnexpectedValue()
294294
assertEquals("com.auth0.android.provider.TokenValidationException: " + message, e.toString());
295295
assertEquals(message, e.getMessage());
296296
}
297+
@Test
298+
public void shouldNotFailWhenOrganizationNameClaimIsRequiredAndHasSameValue() throws Exception {
299+
Map<String, Object> jwtBody = createJWTBody();
300+
jwtBody.put("org_name", EXPECTED_ORGANIZATION_NAME);
301+
String token = createTestJWT("none", jwtBody);
302+
Jwt jwt = new Jwt(token);
303+
options.setOrganization(EXPECTED_ORGANIZATION_NAME);
304+
idTokenVerifier.verify(jwt, options, true);
305+
}
306+
307+
@Test
308+
public void shouldNotFailWhenOrganizationNameClaimIsRequiredAndHasSameValueInDifferentCase() throws Exception {
309+
Map<String, Object> jwtBody = createJWTBody();
310+
jwtBody.put("org_name", "__tESt_OrG_nAme__");
311+
String token = createTestJWT("none", jwtBody);
312+
Jwt jwt = new Jwt(token);
313+
options.setOrganization(EXPECTED_ORGANIZATION_NAME);
314+
idTokenVerifier.verify(jwt, options, true);
315+
}
297316

298317
@Test
299318
public void shouldNotFailWhenOrganizationIdClaimIsMissingButNotRequired() throws Exception {

0 commit comments

Comments
 (0)