-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot get roles with oidc on web application #8719
Comments
@wjsgzcn Which token claim contains the roles info ? |
@wjsgzcn This is how the KC roles are checked: https://github.com/quarkusio/quarkus/blob/master/extensions/oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcUtils.java#L71 We can add more checks if needed (CC @pedroigor, hi Pedro, I recall you were mentioning KC could have the roles in some other claim ? ) |
I don't know which claim, but the same code and same keycloak realm for service application works well. |
@wjsgzcn It is interesting. So in the |
One thing which I suggested earlier but did not get to yet is that in the code flow, we let the users to nominate the AT be used for the rbac/principal; AT in the code flow is for the client application itself to invoke some API on behalf of a user, but if the application is not interested in it and AT is used to represent the user, then I guess we can allow for such a variation too |
@wjsgzcn We have a test where id token has the roles checked but I'm not sure how it is set in Keycloak. |
@wjsgzcn Did you get a chance to enable MP JWT in Keycloak and retry ? Thanks |
@sberyozkin Sorry. Yes, you can enable MP JWT client scope so that tokens are issued using the MP JWT semantics. @wjsgzcn See https://www.keycloak.org/docs/latest/server_admin/#protocol. @sberyozkin I guess this one is not a bug then ? |
Hi @pedroigor I'm planning to do a PR a bit later which can let the users use the access token as the source of the roles in the code flow, I'll CC you :-) |
@wjsgzcn Starting from 1.7.0 it will be possible to use the access token as the source of the roles in the |
Describe the bug
following the guide of https://quarkus.io/guides/security-openid-connect-web-authentication, and I find there is no role based permission control here like https://quarkus.io/guides/security-openid-connect, so I just add @RolesAllowed to some methods and visit, then I get a "Forbidden" text response, but the user logged in is in the role. then I print the roles by "identity.getRoles().size()", and no roles found.
Expected behavior
The roles of user can be read in web applications.
Actual behavior
The roles of user cannot be read, size = 0, and @RolesAllowed method cannot visit even the user has the role.
To Reproduce
Steps to reproduce the behavior:
Configure the keycloak server, and realm, client, user, role
user "admin" is in "admin" role
Run application, and visit http://localhost:8080/hello, input username and password in login page of well-configured keycloak server, login as user "admin"
visit successfully, but the response is "helloadmin0", no roles return.
Visit http://localhost:8080/hello/admin
return "Forbidden"
The text was updated successfully, but these errors were encountered: