-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New Symfony Guard doesn't support user/token refresh/reload #23660
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
@javiereguiluz Please see #19033 |
The token being refreshed is afaik, a bug. It shouldn't be refreshed but logged out and Guard is the only one implementing this properly (as @mvrhov linked, my findings are in that ticket). If you want to update your SecurityObject each request if data changes, don't also use it as security user: https://stovepipe.systems/post/decoupling-your-security-user |
@iltar I understand that you think it's a bug. I also like the idea of a SecurityObject being different to your user entity. However, this doesn't solve the Roles being updated in a users session issue. Updating a users Roles should not require them to log back in. While Voters can be used in some areas, other times simple roles are perfect and work fine, we just need the ability to update the security token when a user's Roles change. Maybe I just need to follow #12025 until a solution is found? |
How can you verify this without re-authenticating?
That's what the
This is actually an issue that comes along from this interface. In fact, the majority of methods in that interface should not be used outside of the authentication process. The only thing you need during the life-cycle of your application, is the identifier. This identifier can be used to retrieve the corresponding entity (if there is any). See #23639 (comment) as of why. |
This is starting to make more sense now. For Roles refresh, we should be writing custom logic, either at the point the roles change, or with a custom event/listener (i.e. What this issue has highlighted for me most, is the misinformation surrounding |
In my scenario this is not the case, I will still query the database to query certain information for a refresh. This is primarily to trigger a de-authentication in certain scenarios, for example: is the user blocked or removed? You can simply return the existing user object, but this user object often contains the password (and salt), which I try to not store in the session whenever I can.
There's a lot of confusion regarding this. Some say it's working like A and consider B a bug, others say it's the other way around, that's why I linked the other post. I'm not sure what the original intention is, but I like the solution done by Guard, as it's explicit and lets developers customize the other scenarios. |
AFAIR, the Johannes said that he modeled security after the one in Java. so IMO it should be looked there for a behavior. |
In #23882 we decided to adopt the behavior described here (guard) no matter which listener is used. Closing here. |
The new Guard system doesn't support refreshing users when they change (i.e. reloading roles), instead forcing the user to be logged out when something changes.
authenticate function in GuardAuthenticationProvider.php, specifically detects we have a PostAuthenticationGuardToken, and throws an AuthenticationExpiredException. This doesn't allow us to update parts of the user, that should normally just cause the user to be refreshed in the security token (if I understand the code correctly).
Previously, when using Authenticators and not Guard, a change to the user would cause the security token to be refreshed. Now it causes an
AuthenticationExpiredException
exception which forces a logout.Not all systems want, or can, use remember_me cookies to allow a logout to then reauthenticate the user when things change. This worked before Guard, so not having it working in Guard is really inconvenient.
The text was updated successfully, but these errors were encountered: