-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
How to get Keycloak's roles? #4811
Comments
It's likely on |
I did the following, still can't be found, even though a user is logged in with an assigned role:
Reopen? |
@fabpico have you checked whether the information you're looking for is getting mapped in the token in the first place? Usually, roles won't be mapped by keycloak unless explicitly enabled. |
as you can see, first callback has roles properly, then its gone and session does not store it, can someone please help with this? I thought that auth.js would have already roles property and i wouldnt have to deal with this. |
Question 💬
How to get keycloak's user roles in next-auth?
I need to check if the user has a certain role to allow/deny him access to certain pages. You can normally do this by checking the
realmAccess.roles
object inside keycloak's token, something like this:const admin = token.realmAccess.roles.includes('admin');
But next-auth's Keycloak token doesn't seem to have a realmAccess object.
How can I get the roles Keycloak has set for my logged in user?
How to reproduce ☕️
Contributing 🙌🏽
No, I am afraid I cannot help regarding this
The text was updated successfully, but these errors were encountered: