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

Skip to content

Commit c2eeb29

Browse files
Merge branch '2.8' into 3.4
* 2.8: Make the simple auth provider the same as in Symfony 2.7.
2 parents a8e284f + 306c627 commit c2eeb29

File tree

2 files changed

+1
-65
lines changed

2 files changed

+1
-65
lines changed

src/Symfony/Component/Security/Core/Authentication/Provider/SimpleAuthenticationProvider.php

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Component\Security\Core\Authentication\Provider;
1313

14-
use Symfony\Component\Security\Core\Exception\AuthenticationServiceException;
15-
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
1614
use Symfony\Component\Security\Core\User\UserChecker;
1715
use Symfony\Component\Security\Core\User\UserCheckerInterface;
1816
use Symfony\Component\Security\Core\User\UserInterface;
@@ -50,20 +48,7 @@ public function authenticate(TokenInterface $token)
5048
$user = $authToken->getUser();
5149

5250
if (!$user instanceof UserInterface) {
53-
try {
54-
$user = $this->userProvider->loadUserByUsername($user);
55-
56-
if (!$user instanceof UserInterface) {
57-
return $authToken;
58-
}
59-
} catch (UsernameNotFoundException $e) {
60-
$e->setUsername($user);
61-
throw $e;
62-
} catch (\Exception $e) {
63-
$e = new AuthenticationServiceException($e->getMessage(), 0, $e);
64-
$e->setToken($token);
65-
throw $e;
66-
}
51+
return $authToken;
6752
}
6853

6954
$this->userChecker->checkPreAuth($user);

src/Symfony/Component/Security/Core/Tests/Authentication/Provider/SimpleAuthenticationProviderTest.php

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use Symfony\Component\Security\Core\Authentication\Provider\SimpleAuthenticationProvider;
1616
use Symfony\Component\Security\Core\Exception\DisabledException;
1717
use Symfony\Component\Security\Core\Exception\LockedException;
18-
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
1918
use Symfony\Component\Security\Core\User\UserChecker;
2019

2120
class SimpleAuthenticationProviderTest extends TestCase
@@ -74,54 +73,6 @@ public function testAuthenticateWhenPostChecksFails()
7473
$provider->authenticate($token);
7574
}
7675

77-
public function testAuthenticateFromString()
78-
{
79-
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
80-
81-
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
82-
$token->expects($this->any())
83-
->method('getUser')
84-
->will($this->returnValue('foo'));
85-
86-
$authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock();
87-
$authenticator->expects($this->once())
88-
->method('authenticateToken')
89-
->will($this->returnValue($token));
90-
91-
$userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock();
92-
$userProvider->expects($this->once())
93-
->method('loadUserByUsername')
94-
->willReturn($this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock());
95-
$provider = $this->getProvider($authenticator, $userProvider);
96-
97-
$this->assertSame($token, $provider->authenticate($token));
98-
}
99-
100-
/**
101-
* @expectedException \Symfony\Component\Security\Core\Exception\UsernameNotFoundException
102-
*/
103-
public function testUsernameNotFound()
104-
{
105-
$user = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
106-
107-
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
108-
$token->expects($this->any())
109-
->method('getUser')
110-
->will($this->returnValue('foo'));
111-
112-
$authenticator = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\SimpleAuthenticatorInterface')->getMock();
113-
$authenticator->expects($this->once())
114-
->method('authenticateToken')
115-
->will($this->returnValue($token));
116-
117-
$userProvider = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserProviderInterface')->getMock();
118-
$userProvider->expects($this->once())
119-
->method('loadUserByUsername')
120-
->willThrowException(new UsernameNotFoundException());
121-
122-
$this->getProvider($authenticator, $userProvider)->authenticate($token);
123-
}
124-
12576
public function testAuthenticateSkipsUserChecksForNonUserInterfaceObjects()
12677
{
12778
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();

0 commit comments

Comments
 (0)