Skip to content

Commit cafe7bf

Browse files
committed
Merge branch '3.3' into 3.4
* 3.3: (22 commits) [Routing] Fix resource miss [Security] Fixed auth provider authenticate() cannot return void declare argument type [FrameworkBundle][Serializer] Move normalizer/encoders definitions to xml file & remove unnecessary checks streamed response should return $this $isClientIpsVali is not used content can be a resource Adding the Form default theme files to be warmed up in Twig's cache Remove BC Break label from `NullDumper` class Username and password in basic auth are allowed to contain '.' Remove obsolete PHPDoc from UriSigner [Serializer] YamlEncoder: throw if the Yaml component isn't installed [Serializer] ObjectNormalizer: throw if PropertyAccess isn't installed [PropertyInfo] Add support for the iterable type pdo session fix Fixed pathinfo calculation for requests starting with a question mark. - fix bad conflict resolving issue - port symfony/symfony#21968 to 3.3+ Fixed unsetting from loosely equal keys OrderedHashMap add DOMElement as return type in Crawler::getIterator to support foreach support in ide Fixed mistake in exception expectation [Debug] Fix same vendor detection in class loader ...
2 parents dbed573 + 70d2be7 commit cafe7bf

8 files changed

+28
-8
lines changed

Authentication/Provider/AnonymousAuthenticationProvider.php

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

1414
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
15+
use Symfony\Component\Security\Core\Exception\AuthenticationException;
1516
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
1617
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;
1718

@@ -44,7 +45,7 @@ public function __construct($secret)
4445
public function authenticate(TokenInterface $token)
4546
{
4647
if (!$this->supports($token)) {
47-
return;
48+
throw new AuthenticationException('The token is not supported by this authentication provider.');
4849
}
4950

5051
if ($this->secret !== $token->getSecret()) {

Authentication/Provider/PreAuthenticatedAuthenticationProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Security\Core\User\UserProviderInterface;
1515
use Symfony\Component\Security\Core\User\UserCheckerInterface;
16+
use Symfony\Component\Security\Core\Exception\AuthenticationException;
1617
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
1718
use Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken;
1819
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
@@ -51,7 +52,7 @@ public function __construct(UserProviderInterface $userProvider, UserCheckerInte
5152
public function authenticate(TokenInterface $token)
5253
{
5354
if (!$this->supports($token)) {
54-
return;
55+
throw new AuthenticationException('The token is not supported by this authentication provider.');
5556
}
5657

5758
if (!$user = $token->getUser()) {

Authentication/Provider/RememberMeAuthenticationProvider.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Security\Core\User\UserCheckerInterface;
1515
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
1616
use Symfony\Component\Security\Core\Authentication\Token\RememberMeToken;
17+
use Symfony\Component\Security\Core\Exception\AuthenticationException;
1718
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
1819

1920
class RememberMeAuthenticationProvider implements AuthenticationProviderInterface
@@ -40,7 +41,7 @@ public function __construct(UserCheckerInterface $userChecker, $secret, $provide
4041
public function authenticate(TokenInterface $token)
4142
{
4243
if (!$this->supports($token)) {
43-
return;
44+
throw new AuthenticationException('The token is not supported by this authentication provider.');
4445
}
4546

4647
if ($this->secret !== $token->getSecret()) {
@@ -49,6 +50,7 @@ public function authenticate(TokenInterface $token)
4950

5051
$user = $token->getUser();
5152
$this->userChecker->checkPreAuth($user);
53+
$this->userChecker->checkPostAuth($user);
5254

5355
$authenticatedToken = new RememberMeToken($user, $this->providerKey, $this->secret);
5456
$authenticatedToken->setAttributes($token->getAttributes());

Authentication/Provider/UserAuthenticationProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function __construct(UserCheckerInterface $userChecker, $providerKey, $hi
5656
public function authenticate(TokenInterface $token)
5757
{
5858
if (!$this->supports($token)) {
59-
return;
59+
throw new AuthenticationException('The token is not supported by this authentication provider.');
6060
}
6161

6262
$username = $token->getUsername();

Tests/Authentication/Provider/AnonymousAuthenticationProviderTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,15 @@ public function testSupports()
2424
$this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
2525
}
2626

27+
/**
28+
* @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationException
29+
* @expectedExceptionMessage The token is not supported by this authentication provider.
30+
*/
2731
public function testAuthenticateWhenTokenIsNotSupported()
2832
{
2933
$provider = $this->getProvider('foo');
3034

31-
$this->assertNull($provider->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
35+
$provider->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
3236
}
3337

3438
/**

Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,15 @@ public function testSupports()
3636
$this->assertFalse($provider->supports($token));
3737
}
3838

39+
/**
40+
* @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationException
41+
* @expectedExceptionMessage The token is not supported by this authentication provider.
42+
*/
3943
public function testAuthenticateWhenTokenIsNotSupported()
4044
{
4145
$provider = $this->getProvider();
4246

43-
$this->assertNull($provider->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
47+
$provider->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
4448
}
4549

4650
/**

Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@ public function testSupports()
2626
$this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
2727
}
2828

29+
/**
30+
* @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationException
31+
* @expectedExceptionMessage The token is not supported by this authentication provider.
32+
*/
2933
public function testAuthenticateWhenTokenIsNotSupported()
3034
{
3135
$provider = $this->getProvider();
3236

3337
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
34-
$this->assertNull($provider->authenticate($token));
38+
$provider->authenticate($token);
3539
}
3640

3741
/**

Tests/Authentication/Provider/UserAuthenticationProviderTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@ public function testSupports()
2929
$this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
3030
}
3131

32+
/**
33+
* @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationException
34+
* @expectedExceptionMessage The token is not supported by this authentication provider.
35+
*/
3236
public function testAuthenticateWhenTokenIsNotSupported()
3337
{
3438
$provider = $this->getProvider();
3539

36-
$this->assertNull($provider->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
40+
$provider->authenticate($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock());
3741
}
3842

3943
/**

0 commit comments

Comments
 (0)