-
-
Notifications
You must be signed in to change notification settings - Fork 334
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
IsGranted Attribute not working on LiveComponents #2521
Comments
Do you have the same problems with default security settings / tools ? |
No, applying #[IsGranted] on a normal Controller works as expected. |
Sorry no, i meant the opposite. Do the IsGranted attribute work on your component, with a more traditional / basic securty settings (firewall / authenticator / etc) ? |
I've pretty much removed everything from the security config and it still is not working. Some additional info: We use keycloak to authenticate our users and create a customized UserInterface DTO. This DTO only contains a few additional properties for conditional rendering. The AuthenticationToken within that DTO is correctly retrieved from the TokenStorage when invoking a normal controller, IsGranted works and everything else does too. Rendering a LiveComponent within a normal Controllers request context - e.g. GET request to a controller which renders a twig template that includes a LiveComponent - the AuthenticationToken is also correctly retrieved. However, when invoking a LiveAction the TokenStorage::getToken() function always returns NULL. I'll try and setup a minimal reproducer in a few days time. |
Do you use custom events / event listeners in your Authenticator ? Could you check the priorities:
|
As per the docs LiveComponents are like normal Symfony controllers, as that you can also use the Attributes you usually use.
However, when a LiveAction is invoked the currently logged in User is null, probably due to some priority settings.
This in turn leads to the #[isGranted] attribute failing - also every other (manual) security check fails, because Security::getUser() always returns null.
Example Code:
My current firewall configuration:
The text was updated successfully, but these errors were encountered: