is there anybody out there who is using Spring Boot Resource Server & Keycloak?
I configured my application.properties with
spring.security.oauth2.resourceserver.jwt.issuer-uri = http://localhost:9080/auth/realms/<myrealm>
In my WebSecurityConfigurerAdapter i can use the client scopes like
.antMatchers(HttpMethod.GET, "/user/**").hasAuthority("SCOPE_read")
but i'm not able to use the roles!
.antMatchers(HttpMethod.GET, "/user/**").hasRole("ADMIN")
The information is availabe in the jwt, but spring does somehow not use it. Do anybody know where i can find a peace of documentation that describes the mapping? Somehow i think there is a node in my head, but where and which one ?
Thats my jwt:
"exp": 1603373908,
"iat": 1603373608,
"jti": "0b18b386-9f62-4c42-810e-692ccc4ed7d1",
"iss": "http://localhost:9080/auth/realms/jhipster",
"aud": "account",
"sub": "4c973896-5761-41fc-8217-07c5d13a004b",
"typ": "Bearer",
"azp": "web_app",
"session_state": "17411db5-8d50-4f25-b520-9a3e8b19fd67",
"acr": "1",
"allowed-origins": [
"*"
],
"realm_access": {
"roles": [
"test",
"ROLE_USER",
"offline_access",
"ROLE_ADMIN",
"uma_authorization"
]
},
"resource_access": {
"account": {
"roles": [
"manage-account",
"manage-account-links",
"view-profile"
]
}
},
"scope": "email profile",
"email_verified": true,
"roles": [
"test",
"ROLE_USER",
"offline_access",
"ROLE_ADMIN",
"uma_authorization"
],
"name": "Admin Administrator",
"preferred_username": "admin",
"given_name": "Admin",
"family_name": "Administrator",
"email": "admin@localhost"
}
Thanks a lot Fredy