Repository navigation
Replies: 2 comments
|
you can either see realm roles or client roles and not both.. this is unfortunate but thats how it is.. :( you can set keycloak.use-resource-role-mappings = false to start using realm roles. if you want both.. the best option is to control it through client scopes and mappers in the keycloak server. |
0 replies
|
Thanks for your reply. Likely my properties have changed since the time of
the original post, but I did change the keycloak.user-resource-mappings =
false, but it still didn't care.
Here's a snippet of what I have so far:
```
keycloak.realm = myrealm
keycloak.auth-server-url = https://auth.mcompanytest.com/auth
keycloak.ssl-required = external
keycloak.resource = ${KEYCLOAK_CLIENT_ID}
keycloak.credentials.secret = ${KEYCLOAK_CLIENT_SECRET}
keycloak.use-resource-role-mappings = false
keycloak.bearer-
#keycloak.realm-key=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAhtC8a3bnj1zFV2ay9OHn+Zqms3aRkzHtF0/9Dy9RRkvUsCigwdltxaWgwzLBUumVkBzvmHn+0Vpw89prrZ4sKYiWFJ72pMYSk6SgWZzvypHjlKGypLyH/jyk/8spSyx0gT5+l4ca8vbo+BA+aVXBCB+ZrrGXYc5iIMDOWvc/MODceOuUX4CNnC4oKjn+du79xxEMN34aAIxvzYy22aiBTwjdLpcNeIpPF8DLGnLK7QOFaEHNH1SJb/9tioZNQf3zTRwX8y7SRBysmEAHKKmD/085NvxZ04OcRZJRzCiMkUYUYuOkN91gYeobl1LU/zK+1SI3penGWpLD9hiVS5xWfQIDAQAB
keycloak.public-client=true
#keycloak.principal-attribute=my-email
```
…On Tue, Jun 21, 2022 at 12:13 PM kkcmadhu ***@***.***> wrote:
you can either see realm roles or client roles and not both.. this is
unfortunate but thats how it is.. :(
you can set keycloak.use-resource-role-mappings = false to start using
realm roles.
if you want both.. the best option is to control it through client scopes
and mappers in the keycloak server.
years ago i raised a an enhancment request, but i thin, its not an issue
for majority of users and hence did not get addressed.
https://issues.redhat.com/browse/KEYCLOAK-8376
—
Reply to this email directly, view it on GitHub
<#12637 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKZEXVLFQTYYCA22CYZHJFDVQHSZRANCNFSM5ZMWIGQA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I'm using Keycloak 12.0.1 (I can't upgrade, please don't ask :) ) and Spring Boot. I thought adding authentication would be possible but is incredibly difficult. I've followed multiple tutorials, each contributing a little and assuming things work, but when I try to use @RolesAllowed, it does not work.
I can authenticate with KC, when I get the security context, I'm seeing data from KC, such as a username, email, etc. However, it refuses to pass the roles. So when I have a @RolesAllowed, it gives me a 403 because the packaging refused to provide the realm role. For testing purposes, I created a client role for the same user, and it refuses to pass that also. I've checked the list of authorities and see things like ROLE_USER, SCOPE_email, SCOPE_openid, and SCOPE_profile. But no relevant role. Initially, I thought it was because I stopped short of using JWT. But when I added JWT, to my SB program, it didn't care. However, when I accessed this same page using Postman, I was able to get a JWT token that had the roles that I wanted.
I get conflicting advice, and as best as possible, I've tried to stick to guides based on Spring Boot and Keycloak. Occaisionally, I've glanced at OAUTH2 guides, but KC is it's own animal.
Attached is SecurityConfiguration to show how I attempted to define authorization and authentication and a snippet from the WorkQueue controller class.
SecurityConfiguration.java:
Snippet from WorkQueueController.java:
When Line A is present, I get a 403 (forbidden). When I comment line A, the method executes, and I'm able to see values I defined in Keycloak:
Snippet of things KC and SB packaging does care to share:
Sanitized snippet of application.properties:
What do I have to do to get Spring Boot+Keycloak to pass in the roles??
All reactions