vendor/crosiersource/crosierlib-base/src/Security/CrosierCoreAuthenticatorTrait.php line 43

Open in your IDE?
  1. <?php
  2. namespace CrosierSource\CrosierLibBaseBundle\Security;
  3. use Psr\Log\LoggerInterface;
  4. use Symfony\Component\HttpFoundation\RedirectResponse;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\HttpFoundation\Response;
  7. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  8. use Symfony\Component\Security\Core\Exception\AuthenticationException;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. use Symfony\Component\Security\Core\User\UserProviderInterface;
  11. use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
  12. use Symfony\Component\Security\Http\Util\TargetPathTrait;
  13. /**
  14.  * Trait CrosierCoreAuthenticatorTrait.
  15.  *
  16.  * Como a autenticação dos crosierapps é feita pelo rememberme, este Authenticator tem apenas a funcionalidade de
  17.  * redirecionar para o login do crosier-core caso não esteja autenticado.
  18.  *
  19.  * @package CrosierSource\CrosierLibBaseBundle\Security
  20.  * @author Carlos Eduardo Pauluk
  21.  */
  22. trait CrosierCoreAuthenticatorTrait
  23. {
  24.     use TargetPathTrait;
  25.     private LoggerInterface $logger;
  26.     /**
  27.      * Ver documentação do pai.
  28.      *
  29.      * @param Request $request
  30.      * @param AuthenticationException|null $authException
  31.      * @return RedirectResponse
  32.      */
  33.     public function start(Request $requestAuthenticationException $authException null)
  34.     {
  35.         $request->getSession()->set('uri_to_redirect_after_login'$request->getUri());
  36.         $url $_SERVER['CROSIERCORE_URL'] ?? null;
  37.         if (!$url) {
  38.             throw new \RuntimeException('CROSIERCORE_URL não informada');
  39.         }
  40.         return new RedirectResponse($url);
  41.     }
  42.     public function supportsRememberMe()
  43.     {
  44.         return true;
  45.     }
  46.     public function supports(Request $request): ?bool
  47.     {
  48.         return false;
  49.     }
  50.     public function getCredentials(Request $request)
  51.     {
  52.         return null;
  53.     }
  54.     public function getUser($credentialsUserProviderInterface $userProvider)
  55.     {
  56.         return null;
  57.     }
  58.     public function checkCredentials($credentialsUserInterface $user)
  59.     {
  60.         return false;
  61.     }
  62.     public function authenticate(Request $request): PassportInterface
  63.     {
  64.         throw new AuthenticationException('authenticate - CrosierCoreAuthenticator do not authenticate');
  65.     }
  66.     public function onAuthenticationFailure(Request $requestAuthenticationException $exception): ?Response
  67.     {
  68.         throw new AuthenticationException('onAuthenticationFailure - CrosierCoreAuthenticator do not authenticate');
  69.     }
  70.     public function onAuthenticationSuccess(Request $requestTokenInterface $tokenstring $firewallName): ?Response
  71.     {
  72.         return null;
  73.     }
  74.     /**
  75.      * @required
  76.      * @param LoggerInterface $logger
  77.      */
  78.     public function setLogger(LoggerInterface $logger): void
  79.     {
  80.         $this->logger $logger;
  81.     }
  82. }