Skip to content

Commit 5aefcc5

Browse files
Merge branch '2.7' into 2.8
* 2.7: [VarDumper] Remove decoration from actual output in tests [Bridge/Doctrine] fix count() notice on PHP 7.2 [Security] Skip user checks if not implementing UserInterface [HttpFoundation] Add HTTP_EARLY_HINTS const [DoctrineBridge] Improve exception message at `IdReader::getIdValue()` fixed CS Use new PHP7.2 functions in hasColorSupport [VarDumper] Fix dumping of SplObjectStorage
2 parents f6908ae + a5d7f9f commit 5aefcc5

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

Authentication/Provider/SimpleAuthenticationProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function authenticate(TokenInterface $token)
5454
$user = $this->userProvider->loadUserByUsername($user);
5555

5656
if (!$user instanceof UserInterface) {
57-
throw new AuthenticationServiceException('The user provider must return a UserInterface object.');
57+
return $authToken;
5858
}
5959
} catch (UsernameNotFoundException $e) {
6060
$e->setUsername($user);

Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
namespace Symfony\Component\Security\Core\Tests\Authentication\Provider;
1313

1414
use PHPUnit\Framework\TestCase;
15-
use Symfony\Component\Security\Core\Exception\DisabledException;
1615
use Symfony\Component\Security\Core\Authentication\Provider\SimpleAuthenticationProvider;
16+
use Symfony\Component\Security\Core\Exception\DisabledException;
1717
use Symfony\Component\Security\Core\Exception\LockedException;
1818
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
19+
use Symfony\Component\Security\Core\User\UserChecker;
1920

2021
class SimpleAuthenticationProviderTest extends TestCase
2122
{
@@ -121,6 +122,20 @@ public function testUsernameNotFound()
121122
$this->getProvider($authenticator, $userProvider)->authenticate($token);
122123
}
123124

125+
public function testAuthenticateSkipsUserChecksForNonUserInterfaceObjects()
126+
{
127+
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
128+
$token->expects($this->any())
129+
->method('getUser')
130+
->will($this->returnValue('string-user'));
131+
$authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock();
132+
$authenticator->expects($this->once())
133+
->method('authenticateToken')
134+
->will($this->returnValue($token));
135+
136+
$this->assertSame($token, $this->getProvider($authenticator, null, new UserChecker())->authenticate($token));
137+
}
138+
124139
protected function getProvider($simpleAuthenticator = null, $userProvider = null, $userChecker = null, $key = 'test')
125140
{
126141
if (null === $userChecker) {

0 commit comments

Comments
 (0)