|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <[email protected]> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\GuardedBundle; |
| 13 | + |
| 14 | +use Symfony\Component\HttpFoundation\Request; |
| 15 | +use Symfony\Component\HttpFoundation\Response; |
| 16 | +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; |
| 17 | +use Symfony\Component\Security\Core\Exception\AuthenticationException; |
| 18 | +use Symfony\Component\Security\Core\User\UserInterface; |
| 19 | +use Symfony\Component\Security\Core\User\UserProviderInterface; |
| 20 | +use Symfony\Component\Security\Guard\AbstractGuardAuthenticator; |
| 21 | + |
| 22 | +class AppCustomAuthenticator extends AbstractGuardAuthenticator |
| 23 | +{ |
| 24 | + public function supports(Request $request): bool |
| 25 | + { |
| 26 | + return '/manual_login' !== $request->getPathInfo() && '/profile' !== $request->getPathInfo(); |
| 27 | + } |
| 28 | + |
| 29 | + public function getCredentials(Request $request) |
| 30 | + { |
| 31 | + throw new AuthenticationException('This should be hit'); |
| 32 | + } |
| 33 | + |
| 34 | + public function getUser($credentials, UserProviderInterface $userProvider): ?UserInterface |
| 35 | + { |
| 36 | + } |
| 37 | + |
| 38 | + public function checkCredentials($credentials, UserInterface $user): bool |
| 39 | + { |
| 40 | + } |
| 41 | + |
| 42 | + public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response |
| 43 | + { |
| 44 | + return new Response('', 418); |
| 45 | + } |
| 46 | + |
| 47 | + public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey): ?Response |
| 48 | + { |
| 49 | + } |
| 50 | + |
| 51 | + public function start(Request $request, ?AuthenticationException $authException = null): Response |
| 52 | + { |
| 53 | + return new Response($authException->getMessage(), Response::HTTP_UNAUTHORIZED); |
| 54 | + } |
| 55 | + |
| 56 | + public function supportsRememberMe(): bool |
| 57 | + { |
| 58 | + } |
| 59 | +} |
0 commit comments