Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 74b6a4c

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

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
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: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,9 @@ 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-
*/
126122
public function testCheckCredentialsReturningNonTrueFailsAuthentication()
127123
{
128-
$this->expectException('Symfony\Component\Security\Core\Exception\BadCredentialsException');
124+
$this->expectException(\TypeError::class);
129125
$providerKey = 'my_uncool_firewall';
130126

131127
$authenticator = $this->getMockBuilder(AuthenticatorInterface::class)->getMock();

0 commit comments

Comments
 (0)