From 60eeacf3bbcbc830919824fbacaf6a9c0ecd0244 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 23 Jan 2024 15:42:10 +0100 Subject: [PATCH] Fix bad merge --- .../AppCustomAuthenticator.php | 57 ------------------ .../GuardedBundle/AppCustomAuthenticator.php | 59 ------------------- .../AuthenticationController.php | 38 ------------ 3 files changed, 154 deletions(-) delete mode 100644 Tests/Functional/Bundle/AnonymousBundle/AppCustomAuthenticator.php delete mode 100644 Tests/Functional/Bundle/GuardedBundle/AppCustomAuthenticator.php delete mode 100644 Tests/Functional/Bundle/GuardedBundle/AuthenticationController.php diff --git a/Tests/Functional/Bundle/AnonymousBundle/AppCustomAuthenticator.php b/Tests/Functional/Bundle/AnonymousBundle/AppCustomAuthenticator.php deleted file mode 100644 index ff3ed7c2..00000000 --- a/Tests/Functional/Bundle/AnonymousBundle/AppCustomAuthenticator.php +++ /dev/null @@ -1,57 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\AnonymousBundle; - -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\AbstractGuardAuthenticator; - -class AppCustomAuthenticator extends AbstractGuardAuthenticator -{ - public function supports(Request $request): bool - { - return false; - } - - public function getCredentials(Request $request) - { - } - - public function getUser($credentials, UserProviderInterface $userProvider): ?UserInterface - { - } - - public function checkCredentials($credentials, UserInterface $user): bool - { - } - - public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response - { - } - - public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey): ?Response - { - } - - public function start(Request $request, ?AuthenticationException $authException = null): Response - { - return new Response($authException->getMessage(), Response::HTTP_UNAUTHORIZED); - } - - public function supportsRememberMe(): bool - { - } -} diff --git a/Tests/Functional/Bundle/GuardedBundle/AppCustomAuthenticator.php b/Tests/Functional/Bundle/GuardedBundle/AppCustomAuthenticator.php deleted file mode 100644 index 91d65fc2..00000000 --- a/Tests/Functional/Bundle/GuardedBundle/AppCustomAuthenticator.php +++ /dev/null @@ -1,59 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\GuardedBundle; - -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\AbstractGuardAuthenticator; - -class AppCustomAuthenticator extends AbstractGuardAuthenticator -{ - public function supports(Request $request): bool - { - return '/manual_login' !== $request->getPathInfo() && '/profile' !== $request->getPathInfo(); - } - - public function getCredentials(Request $request) - { - throw new AuthenticationException('This should be hit'); - } - - public function getUser($credentials, UserProviderInterface $userProvider): ?UserInterface - { - } - - public function checkCredentials($credentials, UserInterface $user): bool - { - } - - public function onAuthenticationFailure(Request $request, AuthenticationException $exception): ?Response - { - return new Response('', 418); - } - - public function onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey): ?Response - { - } - - public function start(Request $request, ?AuthenticationException $authException = null): Response - { - return new Response($authException->getMessage(), Response::HTTP_UNAUTHORIZED); - } - - public function supportsRememberMe(): bool - { - } -} diff --git a/Tests/Functional/Bundle/GuardedBundle/AuthenticationController.php b/Tests/Functional/Bundle/GuardedBundle/AuthenticationController.php deleted file mode 100644 index 97358846..00000000 --- a/Tests/Functional/Bundle/GuardedBundle/AuthenticationController.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\GuardedBundle; - -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Security\Core\User\InMemoryUser; -use Symfony\Component\Security\Core\User\UserInterface; -use Symfony\Component\Security\Guard\GuardAuthenticatorHandler; -use Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken; - -class AuthenticationController -{ - public function manualLoginAction(GuardAuthenticatorHandler $guardAuthenticatorHandler, Request $request) - { - $guardAuthenticatorHandler->authenticateWithToken(new PostAuthenticationGuardToken(new InMemoryUser('Jane', 'test', ['ROLE_USER']), 'secure', ['ROLE_USER']), $request, 'secure'); - - return new Response('Logged in.'); - } - - public function profileAction(?UserInterface $user = null) - { - if (null === $user) { - return new Response('Not logged in.'); - } - - return new Response('Username: '.$user->getUserIdentifier()); - } -}