Skip to content

Commit

Permalink
Fixing case sensitive scope validation issue..
Browse files Browse the repository at this point in the history
  • Loading branch information
prasa7 committed Mar 15, 2022
1 parent 4e0f315 commit 49a816f
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,27 @@ private boolean isUserAuthorizedForScope(String scopeName, String[] userRoles, i
return false;
}


boolean preservedCaseSensitive = Boolean.parseBoolean(System.getProperty("preservedCaseSensitive"));

//Check if the user still has a valid role for this scope.
Set<String> scopeRoles = new HashSet<>(rolesOfScope);
if (!preservedCaseSensitive) {
rolesOfScope.retainAll(Arrays.asList(userRoles));
} else {

for (String roleOfScope : rolesOfScope) {
rolesOfScope.remove(roleOfScope);
rolesOfScope.add(roleOfScope.toLowerCase());
}

ArrayList<String> userRolesLowercase = new ArrayList<>();
for (String userRole : userRoles) {
userRolesLowercase.add(userRole.toLowerCase());
}
rolesOfScope.retainAll(userRolesLowercase);
}

rolesOfScope.retainAll(Arrays.asList(userRoles));

if (rolesOfScope.isEmpty()) {
Expand Down

0 comments on commit 49a816f

Please sign in to comment.