-
Notifications
You must be signed in to change notification settings - Fork 6
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
Guards can not be used with api-tools-mvc-auth #29
Comments
Hi @tems99, I am using LmcRbacMvc in a api-tools apps but only to deny access to some routes, regardless of the authentication status (and I do this because I am using packages that adds routes that I don't want the user to navigate to). The guard listener priority of -5 while the api-tools priority for authentication is -50 if I understand it properly. Can you explain your use case for using a guard (is it a route or controller guard?) that checks user authentication in a api-tools apps? Are you trying to control api calls based on user roles? If so, I think using a route guard may not be the best avenue. api-tools authorization scheme can probably be augmented to use the role providers of LmcRbacMvc but I have not investigated that further. |
I am using api-tools-oauth2. I used the ControllerPermission guards but when I step through the debugger, I noticed that the guards run before the AuthenticatedIdentity is set. I gave up on using guards and instead check permissions in controllers and services. Additional information I am trying to control api calls based on permissions rather than roles. |
Using the guards provided off-the-shelf by LmcRbacMVc will not help here. These guards were not meant to be used with api-tools. However, there are a few options to explore:
This is an interesting use case for developing extensions to LmcRbacMvc to support Rbac in api-tools. I will add this to the list of possible lm-commons packages. So if you try any of these options and you are willing to share your code, let me know so that we can generalize it into a package. |
I completely missed creating custom guards. Will try it.
This is the better approach. I am currently using the existing Authorization functions in api-tools-mvc-auth. Combining them with permissions would certainly be better.
Will certainly do. Thank you for taking the time to reply. |
Hi,
I tried using this with laminas api-tools but can not get the guards working. From my understanding, the guards have a higher priority in the execution of events.
Because they have higher priority, the guards are executed before authentication events in api-tools-mvc-auth. The authenticated identity could not be retrieved by the time the guards are executed.
Does anybody else have the same issues?
The text was updated successfully, but these errors were encountered: