Skip to content

Commit

Permalink
Fix org name verification logic
Browse files Browse the repository at this point in the history
  • Loading branch information
poovamraj committed Jul 18, 2023
1 parent 3761a13 commit 6972a5f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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.equals(orgNameClaim, true)) {
if (organizationInput.lowercase() != orgNameClaim) {
throw OrgNameClaimMismatchException(organizationInput, orgNameClaim)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public void shouldNotFailWhenOrganizationNameClaimIsRequiredAndHasSameValue() th
}

@Test
public void shouldNotFailWhenOrganizationNameClaimIsRequiredAndHasSameValueInDifferentCase() throws Exception {
public void shouldFailWhenInputClaimHasDifferentCaseThanOrgNameReceived() throws Exception {
Map<String, Object> jwtBody = createJWTBody();
jwtBody.put("org_name", "__tESt_OrG_nAme__");
String token = createTestJWT("none", jwtBody);
Expand All @@ -314,6 +314,16 @@ public void shouldNotFailWhenOrganizationNameClaimIsRequiredAndHasSameValueInDif
idTokenVerifier.verify(jwt, options, true);
}

@Test
public void shouldNotFailWhenOrgNameInputHasDifferentCaseThanClaimReceived() 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("__tESt_OrG_nAme__");
idTokenVerifier.verify(jwt, options, true);
}

@Test
public void shouldNotFailWhenOrganizationIdClaimIsMissingButNotRequired() throws Exception {
Map<String, Object> jwtBody = createJWTBody("org_id");
Expand Down

0 comments on commit 6972a5f

Please sign in to comment.