Skip to content

[Security] Fix AuthenticationTrustResolver::isAnonymous() #42732

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

Merged
merged 1 commit into from
Aug 25, 2021

Conversation

chalasr
Copy link
Member

@chalasr chalasr commented Aug 25, 2021

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets #42726
License MIT
Doc PR -

This method wasn't checking if a token is null nor $token->isAuthenticated() until #42650.
Reverting that behavior change fixes tests on both 5.3 and 5.4

Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice thanks

@@ -38,7 +39,11 @@ public function isAnonymous(TokenInterface $token = null/*, $deprecation = true*
trigger_deprecation('symfony/security-core', '5.4', 'The "%s()" method is deprecated, use "isAuthenticated()" or "isFullFledged()" if you want to check if the request is (fully) authenticated.', __METHOD__);
}

return $token && !$this->isAuthenticated($token);
if ($token instanceof AnonymousToken || $token instanceof NullToken || ($token && null === $token->getUser())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return $token instanceof AnonymousToken || $token instanceof NullToken || ($token && !$token->getUser());

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

patch updated, thanks

@nicolas-grekas
Copy link
Member

Thank you @chalasr.

@nicolas-grekas nicolas-grekas merged commit 81c2007 into symfony:5.4 Aug 25, 2021
@chalasr chalasr deleted the fix-isanon branch August 25, 2021 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants