-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
@Security("has_role('ROLE_ADMIN')") "delayed start" when reloading roles? #21861
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
Comments
Can you fork the Symfony Standard Edition and make the changes that are necessary to reproduce your issue? By the way, the |
@xabbuh I have illustrated how you can reproduce the If you want to just use the standard symfony-demo then please do the changes I've made in these two commits:
To play with this from scratch and see how
2 ways to stop giving you access at this point:
OR
|
Thanks for providing the example. I looked into it and found two things:
|
Isn't it related to #12025? |
@HeahDude Partly, the first part of my comment basically sums up what is described in #12025. However, that's something you could work around by letting your custom user class implement the |
Thanks for looking into this @xabbuh Based on your findings:
This is issue is purely to do with
|
The |
When |
Uh oh!
There was an error while loading. Please reload this page.
Let's say you have an admin page that lists users.
On the controller you have
@Security("has_role('ROLE_ADMIN')")
and you load the page while logged in as admin user with the role, all nice.Behind the scenes, remove the association of ROLE_ADMIN to the user (many-to-many table) in the database and in order to force roles to be reloaded let's say change the username from i.e. admin (or whatever you logged in with) to admin1 (or whatever property in order to trigger the hasUserChanged detection and as a result trigger role reload)
Reload the page, roles will get reloaded and it will still let you access the page (!) even though you don't have ROLE_ADMIN anymore. Refresh the page again and it will only now become effective. So you have to refresh twice hence giving you this "last shot" at access (this could be both GET/POST requests).
Now, when you use
@Security("is_granted('ROLE_ADMIN')")
or control via security.yml the change is effective immediately and access is denied - without this "one last shot" as has_role offers.Any ideas?
The text was updated successfully, but these errors were encountered: