-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Returning null from SimplePreAuthenticatorInterface::createToken #11490
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
I stumbled across the same issue the last days. I resolved it in my case by returning an anonymous token with empty credentials like: if (!$this->httpUtils->checkRequestPath($request, $targetUrl)) {
return new PreAuthenticatedToken(
'anon.',
'',
$providerKey
);
} So according to my implementation the authenticateToken() won't authenticate the provided token due to the empty credentials. However it is either an issue with the docs or the actual implementation. If it is an issue just with the docs and my suggestion is ok, I could create an docs PR. /CC @weaverryan @Seldaek |
It's technically an issue with the docs, but I want to fix it in the code because it should allow for a null token in my opinion :). There's actually already a PR open for this - #11414. Nice workaround for the time being @peterrehm |
watching |
@cirovargas You can watch a repository by setting the notification setting. You do not need to actually comment an issue/PR. |
and if you want to watch a single issue, you can use the button in the right column |
…Listener when createToken() not return TokenInterface object (adenkejawen, fabpot) This PR was merged into the 2.4 branch. Discussion ---------- [Security] [Firewall] Bug fixed in SimplePreAuthenticationListener when createToken() not return TokenInterface object | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | no | Fixed tickets | #11490, #11414 | License | MIT | Doc PR | This is a follow-up for #11414 on the right branch. Commits ------- faa8e98 fixed bug e85cb7f added the possibility to return null from SimplePreAuthenticationListener
Symfony cookbook entry for Api Key Authentication states that you can return
null
fromSimplePreAuthenticatorInterface::createToken
. If you don't want to authenticate at certain url:However, when I did it, I got the following error:
createToken
method is called fromSimplePreAuthenticationListener
and when I examined it, this looked like the part that is problematic:So when
SimpleAuthenticator
returnsnull
, it passes thatnull
toAuthenticationManager::authenticate
which doesn't accept nulls:The text was updated successfully, but these errors were encountered: