Ejemplo n.º 1
0
 /**
  * Present a form to the user to accept or not to share
  * its information with the consumer.
  */
 public function allowAction(Request $request)
 {
     $oauth_token = $request->get('oauth_token', null);
     $oauth_callback = $request->get('oauth_callback', null);
     if ($this->securityContext->isGranted('IS_AUTHENTICATED_FULLY')) {
         $token = $this->tokenProvider->loadRequestTokenByToken($oauth_token);
         if ($token instanceof RequestTokenInterface) {
             $this->tokenProvider->setUserForRequestToken($token, $this->securityContext->getToken()->getUser());
             return new Response($this->engine->render('BazingaOAuthServerBundle::authorize.html.twig', array('consumer' => $token->getConsumer(), 'oauth_token' => $oauth_token, 'oauth_callback' => $oauth_callback)));
         }
     }
     throw new HttpException(404);
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function authenticate(TokenInterface $token)
 {
     if (!$this->supports($token)) {
         return null;
     }
     if ($this->serverService->validateRequest($token->getRequestParameters(), $token->getRequestMethod(), $token->getRequestUrl())) {
         $params = $token->getRequestParameters();
         $accessToken = $this->tokenProvider->loadAccessTokenByToken($params['oauth_token']);
         $user = $accessToken->getUser();
         if (null !== $user) {
             $token->setUser($user);
             return $token;
         }
     }
     throw new AuthenticationException('OAuth authentification failed');
 }