-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Symfony custom authenticator still always try to re-authenticate and create a new session for user #54370
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
Feels like the |
I have no errors like this, but here are some logs about the refreshing:
It seems that the user is correctly reloaded from the provider My user implementation cannot be simplier, i just implements UserInterface with 2 custom fields for the tests:
|
Okay, I guess the issue is that your authenticator’s Could you try returning |
Damn i thought the auth process would be automaticly skipped when the user can be retrieved from the session. Works well with the following code:
Guess that was thinked that way. Thank you ! |
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected
6.4.5
Description
Hi everyone,
I'm currently developping a new Symfony 6.4.5 app which needs a custom Authenticator and a custom User Provider.
Basically the reverse proxy behind the application adds a specif http header with a token which should be used by the app to fetch user data through an dedicated external API.
Here is the problem i noticed:
I'm working on mode stateless = false; so i want to authenticate the user and fetch the api only for the first request. The other requests are supposed to retrieve the user from the session but it doesn't behave like that
How to reproduce
Here is the code of my Provider and my custom Authenticator (for my tests, i am very close to the default symfony documentation example):
(security.yaml)
When i try the two scenarios:
1 (first request for a user)
--> enter in "support" function (twice)
--> enter in authenticate function
--> enter in 'loadUserByIdentifier' function a create the user
This scenario works as expected: The user has no session: he is authenticated and the user is loaded from the API and the stored in session.
2 (others requests)
--> enter in 'refreshUser' function( and the user is correctly retrieved from the session)
--> enter in "support" function (twice)
--> enter in authenticate function (again ?)
--> enter in 'loadUserByIdentifier' function and re-create the user
I was expceting to enter only in 'refreshUser' function when the session exists
I'm not using the stateless: true option in this case.
Is this the normal behavior ?
Possible Solution
No response
Additional Context
I found an old similar issue (which was patched) with the 'REMOTE_USER' provider.
#43648
The text was updated successfully, but these errors were encountered: