Answer the question
In order to leave comments, you need to log in
How to correctly pass permissions with a token to the API?
I am using the https://github.com/trikoder/oauth2-bundle over the https://github.com/thephpleague/oauth2-server library . In my project I use these permissions
role_hierarchy:
ROLE_ADMIN:
- ROLE_USER
- ROLE_MANAGE_USERS
- ROLE_MANAGE_CRM
@IsGranted("ROLE_MANAGE_USERS")
. Answer the question
In order to leave comments, you need to log in
If you have an API + a separate front, then it makes little sense to explicitly transfer permissions to the front. When you request a resource, it will be enough for you to receive the current user by a token, check his rights and return 403 (or 401 if the user did not provide a token at all) if they are not enough to access the resource.
In turn, at the front, you will process the response code and display what you need.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question