Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function authenticateToken(TokenInterface $token, UserProviderInterface $userProvider, $providerKey)
 {
     if (is_subclass_of($token->getUser(), $this->userClass)) {
         return new PreAuthenticatedToken($token->getUser(), $token->getCredentials(), $providerKey, $token->getUser()->getRoles());
     }
     $ssoToken = $this->tokenRepository->find($token->getCredentials());
     if (!$ssoToken) {
         throw new AuthenticationException();
     }
     $user = $userProvider->loadUserByUsername($ssoToken->getUsername());
     return new PreAuthenticatedToken($user, $token->getCredentials(), $providerKey, $user->getRoles());
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function onAuthenticationSuccess(Request $request, TokenInterface $token)
 {
     $username = $token->getUsername();
     $returnUrl = $this->determineTargetUrl($request);
     $token = $this->tokenRepository->create($username, $returnUrl);
     $query = http_build_query(['application' => $this->applicationName, 'token' => $token->getId()]);
     $url = $this->authenticateUrl . '?' . $query;
     return $this->httpUtils->createRedirectResponse($request, $url);
 }