KeycloakRole equals only with itself
I use Keycloak Spring Adapter (KSA) to secure existing application. Today I realized that some functions didn't work anymore because of security checking like this: ``` GrantedAuthority adminRole = new MySpecialGrantedAuthority( "superadmin" ); for ( GrantedAuthority role : userRoles ) { if ( role.equals( adminRole ) ) { return true; } } ``` In this example, when I use KSA authorization fails. I believe, that more preferable in `KeycloakRole` use this implementation of `equals` method.
This commit is contained in:
parent
c636b7a1cd
commit
2899375614
1 changed files with 3 additions and 3 deletions
|
@ -51,13 +51,13 @@ public class KeycloakRole implements GrantedAuthority {
|
|||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof KeycloakRole)) {
|
||||
if (!(o instanceof GrantedAuthority)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
KeycloakRole that = (KeycloakRole) o;
|
||||
GrantedAuthority that = (GrantedAuthority) o;
|
||||
|
||||
if (!role.equals(that.role)) {
|
||||
if (!role.equals(that.getAuthority())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue