Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Merge branch '3.3' into 3.4
Browse files Browse the repository at this point in the history
* 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
  ...
  • Loading branch information
fabpot committed Oct 20, 2017
2 parents 7e680ec + d9c35b9 commit dd6a893
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace Symfony\Component\Security\Core\Authentication\Provider;

use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken;

Expand Down Expand Up @@ -44,7 +45,7 @@ public function __construct($secret)
public function authenticate(TokenInterface $token)
{
if (!$this->supports($token)) {
return;
throw new AuthenticationException('The token is not supported by this authentication provider.');
}

if ($this->secret !== $token->getSecret()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Core\User\UserCheckerInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
use Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
Expand Down Expand Up @@ -51,7 +52,7 @@ public function __construct(UserProviderInterface $userProvider, UserCheckerInte
public function authenticate(TokenInterface $token)
{
if (!$this->supports($token)) {
return;
throw new AuthenticationException('The token is not supported by this authentication provider.');
}

if (!$user = $token->getUser()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Symfony\Component\Security\Core\User\UserCheckerInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authentication\Token\RememberMeToken;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Exception\BadCredentialsException;

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

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

$user = $token->getUser();
$this->userChecker->checkPreAuth($user);
$this->userChecker->checkPostAuth($user);

$authenticatedToken = new RememberMeToken($user, $this->providerKey, $this->secret);
$authenticatedToken->setAttributes($token->getAttributes());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __construct(UserCheckerInterface $userChecker, $providerKey, $hi
public function authenticate(TokenInterface $token)
{
if (!$this->supports($token)) {
return;
throw new AuthenticationException('The token is not supported by this authentication provider.');
}

$username = $token->getUsername();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ public function testSupports()
$this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
}

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

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@ public function testSupports()
$this->assertFalse($provider->supports($token));
}

/**
* @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationException
* @expectedExceptionMessage The token is not supported by this authentication provider.
*/
public function testAuthenticateWhenTokenIsNotSupported()
{
$provider = $this->getProvider();

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ public function testSupports()
$this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
}

/**
* @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationException
* @expectedExceptionMessage The token is not supported by this authentication provider.
*/
public function testAuthenticateWhenTokenIsNotSupported()
{
$provider = $this->getProvider();

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

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ public function testSupports()
$this->assertFalse($provider->supports($this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock()));
}

/**
* @expectedException \Symfony\Component\Security\Core\Exception\AuthenticationException
* @expectedExceptionMessage The token is not supported by this authentication provider.
*/
public function testAuthenticateWhenTokenIsNotSupported()
{
$provider = $this->getProvider();

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

/**
Expand Down

0 comments on commit dd6a893

Please sign in to comment.