Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keycloak spring boot configuration for client roles

I have a spring boot enabled rest api configured with keycloak.

keycloak.realm = demo
keycloak.realmKey = yfdsfdiufuydhf
keycloak.auth-server-url = http://localhost:8080/auth
keycloak.ssl-required = external
keycloak.resource = lib-backend
keycloak.bearer-only = true
keycloak.credentials.secret = a9fa2e60-324b-4508-b33d-84be2a981da3
# Keycloak Enable CORS
keycloak.cors = true

keycloak.securityConstraints[0].securityCollections[0].name = spring secured api
keycloak.securityConstraints[0].securityCollections[0].authRoles[0] = lib_sadmin

The above code will return api to client without any issue.But when i remove the realm role and enabled the client role gives 403 forbidden error.

like image 280
boycod3 Avatar asked Apr 17 '17 10:04

boycod3


1 Answers

If you want to operate with the client roles, you should add this to your configuration:

keycloak.use-resource-role-mappings=true

See the documentation.

like image 193
Gex Avatar answered Sep 27 '22 22:09

Gex