diff --git a/src/Symfony/Component/Security/CHANGELOG.md b/src/Symfony/Component/Security/CHANGELOG.md index c8aece01401db..945e3cb3264b4 100644 --- a/src/Symfony/Component/Security/CHANGELOG.md +++ b/src/Symfony/Component/Security/CHANGELOG.md @@ -11,6 +11,8 @@ CHANGELOG * removed support for voters that don't implement the `VoterInterface` * added a sixth `string $context` argument to `LogoutUrlGenerator::registerListener()` * removed HTTP digest authentication + * removed `GuardAuthenticatorInterface` in favor of `AuthenticatorInterface` + * removed `AbstractGuardAuthenticator::supports()` 3.4.0 ----- diff --git a/src/Symfony/Component/Security/Guard/AbstractGuardAuthenticator.php b/src/Symfony/Component/Security/Guard/AbstractGuardAuthenticator.php index 5eceb8470a567..cdfb613593928 100644 --- a/src/Symfony/Component/Security/Guard/AbstractGuardAuthenticator.php +++ b/src/Symfony/Component/Security/Guard/AbstractGuardAuthenticator.php @@ -11,7 +11,6 @@ namespace Symfony\Component\Security\Guard; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Security\Core\User\UserInterface; use Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken; @@ -22,18 +21,6 @@ */ abstract class AbstractGuardAuthenticator implements AuthenticatorInterface { - /** - * {@inheritdoc} - * - * @deprecated since version 3.4, to be removed in 4.0 - */ - public function supports(Request $request) - { - @trigger_error(sprintf('The "%s()" method is deprecated since version 3.4 and will be removed in 4.0. Implement the "%s::supports()" method in class "%s" instead.', __METHOD__, AuthenticatorInterface::class, get_class($this)), E_USER_DEPRECATED); - - return true; - } - /** * Shortcut to create a PostAuthenticationGuardToken for you, if you don't really * care about which authenticated token you're using. diff --git a/src/Symfony/Component/Security/Guard/AuthenticatorInterface.php b/src/Symfony/Component/Security/Guard/AuthenticatorInterface.php index f68b8d6f43b08..10577d74cdffc 100644 --- a/src/Symfony/Component/Security/Guard/AuthenticatorInterface.php +++ b/src/Symfony/Component/Security/Guard/AuthenticatorInterface.php @@ -12,6 +12,13 @@ namespace Symfony\Component\Security\Guard; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; +use Symfony\Component\Security\Core\Exception\AuthenticationException; +use Symfony\Component\Security\Core\User\UserInterface; +use Symfony\Component\Security\Core\User\UserProviderInterface; +use Symfony\Component\Security\Guard\Token\GuardTokenInterface; +use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface; /** * The interface for all "guard" authenticators. @@ -23,7 +30,7 @@ * @author Ryan Weaver * @author Amaury Leroux de Lens */ -interface AuthenticatorInterface extends GuardAuthenticatorInterface +interface AuthenticatorInterface extends AuthenticationEntryPointInterface { /** * Does the authenticator support the given Request? @@ -60,4 +67,104 @@ public function supports(Request $request); * @throws \UnexpectedValueException If null is returned */ public function getCredentials(Request $request); + + /** + * Return a UserInterface object based on the credentials. + * + * The *credentials* are the return value from getCredentials() + * + * You may throw an AuthenticationException if you wish. If you return + * null, then a UsernameNotFoundException is thrown for you. + * + * @param mixed $credentials + * @param UserProviderInterface $userProvider + * + * @throws AuthenticationException + * + * @return UserInterface|null + */ + public function getUser($credentials, UserProviderInterface $userProvider); + + /** + * Returns true if the credentials are valid. + * + * If any value other than true is returned, authentication will + * fail. You may also throw an AuthenticationException if you wish + * to cause authentication to fail. + * + * The *credentials* are the return value from getCredentials() + * + * @param mixed $credentials + * @param UserInterface $user + * + * @return bool + * + * @throws AuthenticationException + */ + public function checkCredentials($credentials, UserInterface $user); + + /** + * Create an authenticated token for the given user. + * + * If you don't care about which token class is used or don't really + * understand what a "token" is, you can skip this method by extending + * the AbstractGuardAuthenticator class from your authenticator. + * + * @see AbstractGuardAuthenticator + * + * @param UserInterface $user + * @param string $providerKey The provider (i.e. firewall) key + * + * @return GuardTokenInterface + */ + public function createAuthenticatedToken(UserInterface $user, $providerKey); + + /** + * Called when authentication executed, but failed (e.g. wrong username password). + * + * This should return the Response sent back to the user, like a + * RedirectResponse to the login page or a 403 response. + * + * If you return null, the request will continue, but the user will + * not be authenticated. This is probably not what you want to do. + * + * @param Request $request + * @param AuthenticationException $exception + * + * @return Response|null + */ + public function onAuthenticationFailure(Request $request, AuthenticationException $exception); + + /** + * Called when authentication executed and was successful! + * + * This should return the Response sent back to the user, like a + * RedirectResponse to the last page they visited. + * + * If you return null, the current request will continue, and the user + * will be authenticated. This makes sense, for example, with an API. + * + * @param Request $request + * @param TokenInterface $token + * @param string $providerKey The provider (i.e. firewall) key + * + * @return Response|null + */ + public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey); + + /** + * Does this method support remember me cookies? + * + * Remember me cookie will be set if *all* of the following are met: + * A) This method returns true + * B) The remember_me key under your firewall is configured + * C) The "remember me" functionality is activated. This is usually + * done by having a _remember_me checkbox in your form, but + * can be configured by the "always_remember_me" and "remember_me_parameter" + * parameters under the "remember_me" firewall key + * D) The onAuthenticationSuccess method returns a Response object + * + * @return bool + */ + public function supportsRememberMe(); } diff --git a/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php b/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php index 4ec0b8f32630d..0e2c7d91b2533 100644 --- a/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php +++ b/src/Symfony/Component/Security/Guard/Firewall/GuardAuthenticationListener.php @@ -15,10 +15,9 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\Security\Guard\GuardAuthenticatorHandler; -use Symfony\Component\Security\Guard\GuardAuthenticatorInterface; +use Symfony\Component\Security\Guard\AuthenticatorInterface; use Symfony\Component\Security\Guard\Token\PreAuthenticationGuardToken; use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface; -use Symfony\Component\Security\Guard\AuthenticatorInterface; use Psr\Log\LoggerInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; @@ -94,7 +93,7 @@ public function handle(GetResponseEvent $event) } } - private function executeGuardAuthenticator($uniqueGuardKey, GuardAuthenticatorInterface $guardAuthenticator, GetResponseEvent $event) + private function executeGuardAuthenticator($uniqueGuardKey, AuthenticatorInterface $guardAuthenticator, GetResponseEvent $event) { $request = $event->getRequest(); try { @@ -103,27 +102,14 @@ private function executeGuardAuthenticator($uniqueGuardKey, GuardAuthenticatorIn } // abort the execution of the authenticator if it doesn't support the request - if ($guardAuthenticator instanceof AuthenticatorInterface) { - if (!$guardAuthenticator->supports($request)) { - return; - } - // as there was a support for given request, - // authenticator is expected to give not-null credentials. - $credentialsCanBeNull = false; - } else { - // deprecated since version 3.4, to be removed in 4.0 - $credentialsCanBeNull = true; + if (!$guardAuthenticator->supports($request)) { + return; } // allow the authenticator to fetch authentication info from the request $credentials = $guardAuthenticator->getCredentials($request); if (null === $credentials) { - // deprecated since version 3.4, to be removed in 4.0 - if ($credentialsCanBeNull) { - return; - } - throw new \UnexpectedValueException(sprintf('The return value of "%s::getCredentials()" must not be null. Return false from "%s::supports()" instead.', get_class($guardAuthenticator), get_class($guardAuthenticator))); } @@ -196,7 +182,7 @@ public function setRememberMeServices(RememberMeServicesInterface $rememberMeSer * @param TokenInterface $token * @param Response $response */ - private function triggerRememberMe(GuardAuthenticatorInterface $guardAuthenticator, Request $request, TokenInterface $token, Response $response = null) + private function triggerRememberMe(AuthenticatorInterface $guardAuthenticator, Request $request, TokenInterface $token, Response $response = null) { if (null === $this->rememberMeServices) { if (null !== $this->logger) { diff --git a/src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php b/src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php index abe263d888d5f..8bec87c318d80 100644 --- a/src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php +++ b/src/Symfony/Component/Security/Guard/GuardAuthenticatorHandler.php @@ -70,7 +70,7 @@ public function authenticateWithToken(TokenInterface $token, Request $request) * * @return null|Response */ - public function handleAuthenticationSuccess(TokenInterface $token, Request $request, GuardAuthenticatorInterface $guardAuthenticator, $providerKey) + public function handleAuthenticationSuccess(TokenInterface $token, Request $request, AuthenticatorInterface $guardAuthenticator, $providerKey) { $response = $guardAuthenticator->onAuthenticationSuccess($request, $token, $providerKey); @@ -97,7 +97,7 @@ public function handleAuthenticationSuccess(TokenInterface $token, Request $requ * * @return Response|null */ - public function authenticateUserAndHandleSuccess(UserInterface $user, Request $request, GuardAuthenticatorInterface $authenticator, $providerKey) + public function authenticateUserAndHandleSuccess(UserInterface $user, Request $request, AuthenticatorInterface $authenticator, $providerKey) { // create an authenticated token for the User $token = $authenticator->createAuthenticatedToken($user, $providerKey); @@ -119,7 +119,7 @@ public function authenticateUserAndHandleSuccess(UserInterface $user, Request $r * * @return null|Response */ - public function handleAuthenticationFailure(AuthenticationException $authenticationException, Request $request, GuardAuthenticatorInterface $guardAuthenticator, $providerKey) + public function handleAuthenticationFailure(AuthenticationException $authenticationException, Request $request, AuthenticatorInterface $guardAuthenticator, $providerKey) { $token = $this->tokenStorage->getToken(); if ($token instanceof PostAuthenticationGuardToken && $providerKey === $token->getProviderKey()) { diff --git a/src/Symfony/Component/Security/Guard/GuardAuthenticatorInterface.php b/src/Symfony/Component/Security/Guard/GuardAuthenticatorInterface.php deleted file mode 100644 index 0d11573c03b11..0000000000000 --- a/src/Symfony/Component/Security/Guard/GuardAuthenticatorInterface.php +++ /dev/null @@ -1,163 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Security\Guard; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; -use Symfony\Component\Security\Core\Exception\AuthenticationException; -use Symfony\Component\Security\Core\User\UserInterface; -use Symfony\Component\Security\Core\User\UserProviderInterface; -use Symfony\Component\Security\Guard\Token\GuardTokenInterface; -use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface; - -/** - * The interface for all "guard" authenticators. - * - * The methods on this interface are called throughout the guard authentication - * process to give you the power to control most parts of the process from - * one location. - * - * @author Ryan Weaver - * - * @deprecated since version 3.4, to be removed in 4.0. Use AuthenticatorInterface instead - */ -interface GuardAuthenticatorInterface extends AuthenticationEntryPointInterface -{ - /** - * Get the authentication credentials from the request and return them - * as any type (e.g. an associate array). If you return null, authentication - * will be skipped. - * - * Whatever value you return here will be passed to getUser() and checkCredentials() - * - * For example, for a form login, you might: - * - * if ($request->request->has('_username')) { - * return array( - * 'username' => $request->request->get('_username'), - * 'password' => $request->request->get('_password'), - * ); - * } else { - * return; - * } - * - * Or for an API token that's on a header, you might use: - * - * return array('api_key' => $request->headers->get('X-API-TOKEN')); - * - * @param Request $request - * - * @return mixed|null - */ - public function getCredentials(Request $request); - - /** - * Return a UserInterface object based on the credentials. - * - * The *credentials* are the return value from getCredentials() - * - * You may throw an AuthenticationException if you wish. If you return - * null, then a UsernameNotFoundException is thrown for you. - * - * @param mixed $credentials - * @param UserProviderInterface $userProvider - * - * @throws AuthenticationException - * - * @return UserInterface|null - */ - public function getUser($credentials, UserProviderInterface $userProvider); - - /** - * Returns true if the credentials are valid. - * - * If any value other than true is returned, authentication will - * fail. You may also throw an AuthenticationException if you wish - * to cause authentication to fail. - * - * The *credentials* are the return value from getCredentials() - * - * @param mixed $credentials - * @param UserInterface $user - * - * @return bool - * - * @throws AuthenticationException - */ - public function checkCredentials($credentials, UserInterface $user); - - /** - * Create an authenticated token for the given user. - * - * If you don't care about which token class is used or don't really - * understand what a "token" is, you can skip this method by extending - * the AbstractGuardAuthenticator class from your authenticator. - * - * @see AbstractGuardAuthenticator - * - * @param UserInterface $user - * @param string $providerKey The provider (i.e. firewall) key - * - * @return GuardTokenInterface - */ - public function createAuthenticatedToken(UserInterface $user, $providerKey); - - /** - * Called when authentication executed, but failed (e.g. wrong username password). - * - * This should return the Response sent back to the user, like a - * RedirectResponse to the login page or a 403 response. - * - * If you return null, the request will continue, but the user will - * not be authenticated. This is probably not what you want to do. - * - * @param Request $request - * @param AuthenticationException $exception - * - * @return Response|null - */ - public function onAuthenticationFailure(Request $request, AuthenticationException $exception); - - /** - * Called when authentication executed and was successful! - * - * This should return the Response sent back to the user, like a - * RedirectResponse to the last page they visited. - * - * If you return null, the current request will continue, and the user - * will be authenticated. This makes sense, for example, with an API. - * - * @param Request $request - * @param TokenInterface $token - * @param string $providerKey The provider (i.e. firewall) key - * - * @return Response|null - */ - public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey); - - /** - * Does this method support remember me cookies? - * - * Remember me cookie will be set if *all* of the following are met: - * A) This method returns true - * B) The remember_me key under your firewall is configured - * C) The "remember me" functionality is activated. This is usually - * done by having a _remember_me checkbox in your form, but - * can be configured by the "always_remember_me" and "remember_me_parameter" - * parameters under the "remember_me" firewall key - * D) The onAuthenticationSuccess method returns a Response object - * - * @return bool - */ - public function supportsRememberMe(); -} diff --git a/src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php b/src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php index 1789b95d8c4ed..e9759cd4f2ec0 100644 --- a/src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/Authenticator/FormLoginAuthenticatorTest.php @@ -104,6 +104,11 @@ class TestFormLoginAuthenticator extends AbstractFormLoginAuthenticator private $loginUrl; private $defaultSuccessRedirectUrl; + public function supports(Request $request) + { + return true; + } + public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey) { } diff --git a/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php b/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php index 5af9f130f8645..e4a47fd8f0eb9 100644 --- a/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/Firewall/GuardAuthenticationListenerTest.php @@ -17,7 +17,6 @@ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Guard\AuthenticatorInterface; use Symfony\Component\Security\Guard\Firewall\GuardAuthenticationListener; -use Symfony\Component\Security\Guard\GuardAuthenticatorInterface; use Symfony\Component\Security\Guard\Token\PreAuthenticationGuardToken; use Symfony\Component\Security\Core\Exception\AuthenticationException; @@ -207,131 +206,6 @@ public function testHandleCatchesAuthenticationException() $listener->handle($this->event); } - /** - * @group legacy - */ - public function testLegacyInterfaceNullCredentials() - { - $authenticatorA = $this->getMockBuilder(GuardAuthenticatorInterface::class)->getMock(); - $providerKey = 'my_firewall3'; - - $authenticatorA - ->expects($this->once()) - ->method('getCredentials') - ->will($this->returnValue(null)); - - // this is not called - $this->authenticationManager - ->expects($this->never()) - ->method('authenticate'); - - $this->guardAuthenticatorHandler - ->expects($this->never()) - ->method('handleAuthenticationSuccess'); - - $listener = new GuardAuthenticationListener( - $this->guardAuthenticatorHandler, - $this->authenticationManager, - $providerKey, - array($authenticatorA), - $this->logger - ); - - $listener->handle($this->event); - } - - /** - * @group legacy - */ - public function testLegacyInterfaceKeepsWorking() - { - $authenticator = $this->getMockBuilder(GuardAuthenticatorInterface::class)->getMock(); - $authenticateToken = $this->getMockBuilder(TokenInterface::class)->getMock(); - $providerKey = 'my_firewall'; - - $credentials = array('username' => 'weaverryan', 'password' => 'all_your_base'); - - $authenticator - ->expects($this->once()) - ->method('getCredentials') - ->with($this->equalTo($this->request)) - ->will($this->returnValue($credentials)); - - // a clone of the token that should be created internally - $uniqueGuardKey = 'my_firewall_0'; - $nonAuthedToken = new PreAuthenticationGuardToken($credentials, $uniqueGuardKey); - - $this->authenticationManager - ->expects($this->once()) - ->method('authenticate') - ->with($this->equalTo($nonAuthedToken)) - ->will($this->returnValue($authenticateToken)); - - $this->guardAuthenticatorHandler - ->expects($this->once()) - ->method('authenticateWithToken') - ->with($authenticateToken, $this->request); - - $this->guardAuthenticatorHandler - ->expects($this->once()) - ->method('handleAuthenticationSuccess') - ->with($authenticateToken, $this->request, $authenticator, $providerKey); - - $listener = new GuardAuthenticationListener( - $this->guardAuthenticatorHandler, - $this->authenticationManager, - $providerKey, - array($authenticator), - $this->logger - ); - - $listener->setRememberMeServices($this->rememberMeServices); - // should never be called - our handleAuthenticationSuccess() does not return a Response - $this->rememberMeServices - ->expects($this->never()) - ->method('loginSuccess'); - - $listener->handle($this->event); - } - - /** - * @group legacy - */ - public function testReturnNullToSkipAuth() - { - $authenticatorA = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); - $authenticatorB = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); - $providerKey = 'my_firewall3'; - - $authenticatorA - ->expects($this->once()) - ->method('getCredentials') - ->will($this->returnValue(null)); - $authenticatorB - ->expects($this->once()) - ->method('getCredentials') - ->will($this->returnValue(null)); - - // this is not called - $this->authenticationManager - ->expects($this->never()) - ->method('authenticate'); - - $this->guardAuthenticatorHandler - ->expects($this->never()) - ->method('handleAuthenticationSuccess'); - - $listener = new GuardAuthenticationListener( - $this->guardAuthenticatorHandler, - $this->authenticationManager, - $providerKey, - array($authenticatorA, $authenticatorB), - $this->logger - ); - - $listener->handle($this->event); - } - public function testSupportsReturnFalseSkipAuth() { $authenticator = $this->getMockBuilder(AuthenticatorInterface::class)->getMock(); diff --git a/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php b/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php index 9d8301fce8011..71b53f62f36b2 100644 --- a/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php +++ b/src/Symfony/Component/Security/Guard/Tests/Provider/GuardAuthenticationProviderTest.php @@ -86,68 +86,6 @@ public function testAuthenticate() $this->assertSame($authedToken, $actualAuthedToken); } - /** - * @group legacy - */ - public function testLegacyAuthenticate() - { - $providerKey = 'my_cool_firewall'; - - $authenticatorA = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); - $authenticatorB = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); - $authenticatorC = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); - $authenticators = array($authenticatorA, $authenticatorB, $authenticatorC); - - // called 2 times - for authenticator A and B (stops on B because of match) - $this->preAuthenticationToken->expects($this->exactly(2)) - ->method('getGuardProviderKey') - // it will return the "1" index, which will match authenticatorB - ->will($this->returnValue('my_cool_firewall_1')); - - $enteredCredentials = array( - 'username' => '_weaverryan_test_user', - 'password' => 'guard_auth_ftw', - ); - $this->preAuthenticationToken->expects($this->atLeastOnce()) - ->method('getCredentials') - ->will($this->returnValue($enteredCredentials)); - - // authenticators A and C are never called - $authenticatorA->expects($this->never()) - ->method('getUser'); - $authenticatorC->expects($this->never()) - ->method('getUser'); - - $mockedUser = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock(); - $authenticatorB->expects($this->once()) - ->method('getUser') - ->with($enteredCredentials, $this->userProvider) - ->will($this->returnValue($mockedUser)); - // checkCredentials is called - $authenticatorB->expects($this->once()) - ->method('checkCredentials') - ->with($enteredCredentials, $mockedUser) - // authentication works! - ->will($this->returnValue(true)); - $authedToken = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock(); - $authenticatorB->expects($this->once()) - ->method('createAuthenticatedToken') - ->with($mockedUser, $providerKey) - ->will($this->returnValue($authedToken)); - - // user checker should be called - $this->userChecker->expects($this->once()) - ->method('checkPreAuth') - ->with($mockedUser); - $this->userChecker->expects($this->once()) - ->method('checkPostAuth') - ->with($mockedUser); - - $provider = new GuardAuthenticationProvider($authenticators, $this->userProvider, $providerKey, $this->userChecker); - $actualAuthedToken = $provider->authenticate($this->preAuthenticationToken); - $this->assertSame($authedToken, $actualAuthedToken); - } - /** * @expectedException \Symfony\Component\Security\Core\Exception\BadCredentialsException */ @@ -155,7 +93,7 @@ public function testCheckCredentialsReturningNonTrueFailsAuthentication() { $providerKey = 'my_uncool_firewall'; - $authenticator = $this->getMockBuilder('Symfony\Component\Security\Guard\GuardAuthenticatorInterface')->getMock(); + $authenticator = $this->getMockBuilder(AuthenticatorInterface::class)->getMock(); // make sure the authenticator is used $this->preAuthenticationToken->expects($this->any())