Skip to content
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

Retrieve user roles #5

Closed
wants to merge 1 commit into from

Conversation

nazonhou
Copy link

Most of the time, when I work with Keycloak, I need to protect some routes or even some parts of my views based on the roles associated to the user on keycloak.

But, unfortunately, we don't have any method or even function to retrieve directly user roles in this package, unless we make some request to keycloak.

I thought that it can be hepful for the community to have such method so I write it. It just decode the access_token to retrieve the user roles.

To decode the token I use the firebase/php-jwt package. But if you don't want more dependency, I can do it by my own.

To decode the token, I use also the realm's public key which the user can provide via the env variable KEYCLOAK_PUBLIC_KEY. But it's optional actually. So, when it's not set, I retrieve it by my own.

I hope that you will appreciate it and please let me know if you find any issue or suggestion on my code.

Regards

@socialiteprovidersbot
Copy link

This repository is a READ ONLY subtree split from SocialiteProviders/Providers.

Please open a PR against SocialiteProviders/Providers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants