-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Security] Avoid refreshing user when TokenInterface::getUser()
returns null
#59560
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
Conversation
alexandre-daubois
commented
Jan 20, 2025
Q | A |
---|---|
Branch? | 6.4 |
Bug fix? | yes |
New feature? | no |
Deprecations? | no |
Issues | Fix #59559 |
License | MIT |
I don’t think this makes sense since only authenticated tokens (aka tokens with a user) are serialized into the session, meaning |
I think this should be covered, the added test shows that the code can fail with a token without a user. Also the issue author gives a reproducer. I suggest adding this check, so even in the case of an unlikely event of this happening, the component code doesn't crash. |
/cc @jorrit WDYT? |
I thought I was replying on the proposed code change. Anyway, returning null is best for me as the code is not part of a path that I control. Otherwise, an exception handler in the stack until This is the stack trace until If returning null is not acceptable, I could just try to return a user with a different identifier to get the behavior I want. I just need a way to deauthenticate a user automatically when its underlying token expires. |
Listening on |
Couldn’t this be implemented using the underlying library token constraints? https://github.com/Drenso/symfony-oidc?tab=readme-ov-file#additional-token-claim-validation |
Looks like there are many alternatives to achieve what's needed. Considering this and |
An exception could still be appropriate to inform the developer they made something unexpected?
? |
Should a defensive mechanism still be added? In the current state, the underlying code and logic can fail and lead to an unmanaged PHP error |
I agree that this would be better than running into a PHP error. |
Fair, PR welcome 👍 |
Nice, I'll take care of it 🙂 |
… with a null user (alexandre-daubois) This PR was merged into the 6.4 branch. Discussion ---------- [Security] Throw an explicit error when refreshing a token with a null user | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #59559 | License | MIT Follwing #59560 (comment), to prevent the code to simply fail and return an explicit message to the user. Commits ------- cd427c3 [Security] Throw an explicit error when authenticating a token with a null user