Skip to content

Commit

Permalink
Add case insensitive check
Browse files Browse the repository at this point in the history
  • Loading branch information
poovamraj committed Jul 17, 2023
1 parent bf4abd4 commit ee5b61c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ internal class IdTokenVerifier {
if (TextUtils.isEmpty(orgNameClaim)) {
throw OrgNameClaimMissingException()
}
if (organizationInput != orgNameClaim) {
if (!organizationInput.equals(orgNameClaim, true)) {
throw OrgNameClaimMismatchException(organizationInput, orgNameClaim)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,25 @@ public void shouldFailWhenOrganizationNameClaimIsRequiredAndHasUnexpectedValue()
assertEquals("com.auth0.android.provider.TokenValidationException: " + message, e.toString());
assertEquals(message, e.getMessage());
}
@Test
public void shouldNotFailWhenOrganizationNameClaimIsRequiredAndHasSameValue() throws Exception {
Map<String, Object> jwtBody = createJWTBody();
jwtBody.put("org_name", EXPECTED_ORGANIZATION_NAME);
String token = createTestJWT("none", jwtBody);
Jwt jwt = new Jwt(token);
options.setOrganization(EXPECTED_ORGANIZATION_NAME);
idTokenVerifier.verify(jwt, options, true);
}

@Test
public void shouldNotFailWhenOrganizationNameClaimIsRequiredAndHasSameValueInDifferentCase() throws Exception {
Map<String, Object> jwtBody = createJWTBody();
jwtBody.put("org_name", "__tESt_OrG_nAme__");
String token = createTestJWT("none", jwtBody);
Jwt jwt = new Jwt(token);
options.setOrganization(EXPECTED_ORGANIZATION_NAME);
idTokenVerifier.verify(jwt, options, true);
}

@Test
public void shouldNotFailWhenOrganizationIdClaimIsMissingButNotRequired() throws Exception {
Expand Down

0 comments on commit ee5b61c

Please sign in to comment.