Skip to content

Commit 6a66e19

Browse files
committed
drop support for non-boolean return values from checkCredentials()
1 parent 2cee7f2 commit 6a66e19

File tree

3 files changed

+3
-36
lines changed

3 files changed

+3
-36
lines changed

src/Symfony/Component/Security/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ CHANGELOG
44
5.0.0
55
-----
66

7+
* Implementations of `Guard\AuthenticatorInterface::checkCredentials()` must return
8+
a boolean value now. Please explicitly return `false` to indicate invalid credentials.
79
* The `LdapUserProvider` class has been removed, use `Symfony\Component\Ldap\Security\LdapUserProvider` instead.
810
* The `FirewallMapInterface::getListeners()` method must return an array of 3 elements.
911
* Removed the `ContextListener::setLogoutOnUserChange()` method.

src/Symfony/Component/Security/Guard/Provider/GuardAuthenticationProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ private function authenticateViaGuard(AuthenticatorInterface $guardAuthenticator
115115
$this->userChecker->checkPreAuth($user);
116116
if (true !== $checkCredentialsResult = $guardAuthenticator->checkCredentials($token->getCredentials(), $user)) {
117117
if (false !== $checkCredentialsResult) {
118-
@trigger_error(sprintf('%s::checkCredentials() must return a boolean value. You returned %s. This behavior is deprecated in Symfony 4.4 and will trigger a TypeError in Symfony 5.', \get_class($guardAuthenticator), \is_object($checkCredentialsResult) ? \get_class($checkCredentialsResult) : \gettype($checkCredentialsResult)), E_USER_DEPRECATED);
118+
throw new \TypeError(sprintf('%s::checkCredentials() must return a boolean value.', \get_class($guardAuthenticator)));
119119
}
120120

121121
throw new BadCredentialsException(sprintf('Authentication failed because %s::checkCredentials() did not return true.', \get_class($guardAuthenticator)));

src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -119,41 +119,6 @@ public function testCheckCredentialsReturningFalseFailsAuthentication()
119119
$provider->authenticate($this->preAuthenticationToken);
120120
}
121121

122-
/**
123-
* @group legacy
124-
* @expectedDeprecation %s::checkCredentials() must return a boolean value. You returned NULL. This behavior is deprecated in Symfony 4.4 and will trigger a TypeError in Symfony 5.
125-
*/
126-
public function testCheckCredentialsReturningNonTrueFailsAuthentication()
127-
{
128-
$this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
129-
$providerKey = 'my_uncool_firewall';
130-
131-
$authenticator = $this->getMockBuilder(AuthenticatorInterface::class)->getMock();
132-
133-
// make sure the authenticator is used
134-
$this->preAuthenticationToken->expects($this->any())
135-
->method('getGuardProviderKey')
136-
// the 0 index, to match the only authenticator
137-
->willReturn('my_uncool_firewall_0');
138-
139-
$this->preAuthenticationToken->expects($this->atLeastOnce())
140-
->method('getCredentials')
141-
->willReturn('non-null-value');
142-
143-
$mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
144-
$authenticator->expects($this->once())
145-
->method('getUser')
146-
->willReturn($mockedUser);
147-
// checkCredentials is called
148-
$authenticator->expects($this->once())
149-
->method('checkCredentials')
150-
// authentication fails :(
151-
->willReturn(null);
152-
153-
$provider = new GuardAuthenticationProvider([$authenticator], $this->userProvider, $providerKey, $this->userChecker);
154-
$provider->authenticate($this->preAuthenticationToken);
155-
}
156-
157122
public function testGuardWithNoLongerAuthenticatedTriggersLogout()
158123
{
159124
$this->expectException('Symfony\Component\Security\Core\Exception\AuthenticationExpiredException');

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy