Create a new JWT token object from the token in the request

@param Request|null $request

@return JwtToken

@throws NoTokenException
323561
public function jwtToken($request = null)
    {
        $token = $this->getToken($request);
        if( ! $token) throw new NoTokenException('JWT token is required.');

        $driver = $this->makeDriver();
        $jwt = new JwtToken($driver);
        $jwt->setToken($token);

        return $jwt;
    }
763646
public function signRequest($request, $token = null)
    {
        $params = $request->getData();

        if (isset($params['oauth_signature_method']) || $request->hasHeaders() && $request->getHeaders()->has('authorization')) {
            // avoid double sign of request
            return;
        }

        if (empty($params)) {
            $params = $this->generateCommonRequestParams();
        } else {
            $params = array_merge($this->generateCommonRequestParams(), $params);
        }

        $url = $request->getFullUrl();

        $signatureMethod = $this->getSignatureMethod();

        $params['oauth_signature_method'] = $signatureMethod->getName();
        $signatureBaseString = $this->composeSignatureBaseString($request->getMethod(), $url, $params);
        $signatureKey = $this->composeSignatureKey($token);
        $params['oauth_signature'] = $signatureMethod->generateSignature($signatureBaseString, $signatureKey);

        if ($this->authorizationHeaderMethods === null || in_array(strtoupper($request->getMethod()), array_map('strtoupper', $this->authorizationHeaderMethods), true)) {
            $authorizationHeader = $this->composeAuthorizationHeader($params);
            if (!empty($authorizationHeader)) {
                $request->addHeaders($authorizationHeader);

                // removing authorization header params, avoiding duplicate param server error :
                foreach ($params as $key => $value) {
                    if (substr_compare($key, 'oauth', 0, 5) === 0) {
                        unset($params[$key]);
                    }
                }
            }
        }

        $request->setData($params);
    }
1097732
public function authenticate(Request $request)
    {
        $this->checkForToken($request);

        try {
            if (! $this->auth->parseToken()->authenticate()) {
                throw new UnauthorizedHttpException('jwTauth', 'User not found');
            }
        } catch (JwTException $e) {
            throw new UnauthorizedHttpException('jwTauth', $e->getMessage(), $e, $e->getCode());
        }
    }
573742
public function postAction(Request $request)
    {
        try {
            return $this->createJsonResponse($this->get('oauth.server')->grant(
                $this->getRequestData($request, 'snakelize')
            ));
        } catch (InvalidGrantException $e) {
            return new JsonResponse('Unavailable to create access token : bad credentials.', 401);
        } catch (\InvalidArgumentException $e) {
            return new JsonResponse('Invalid or missing fields for grant type.', 400);
        }
    }
356443
protected function getToken(Request $request)
    {
        try {
            $this->validateAuthorizationHeader($request);

            $token = $this->parseAuthorizationHeader($request);
        } catch (Exception $exception) {
            if (! $token = $request->query('token', false)) {
                throw $exception;
            }
        }

        return $token;
    }
506897
public function markNew(Request $request)
    {
        $this->authorize('markNewThreadsAsRead');

        $threads = $this->indexNew($request)->getOriginalContent();

        $primaryKey = auth()->user()->getKeyName();
        $userID = auth()->user()->{$primaryKey};

        $threads->transform(function ($thread) use ($userID)
        {
            return $thread->markAsRead($userID);
        });

        return $this->response($threads, $this->trans('marked_read'));
    }
134841
public function execute( Request $request )
    {
        $controllerClass = $request->attributes->get('_controller');
        if( !($this->isJwtRequired($controllerClass))) {
            return null;
        }

        if( !$this->authoriser->isAuthorised( $request ) ) {
            return new JsonResponse( ['error' => 'Invalid token'], 403 );
        }
        return null;
    }
591195
public function fetchToken(Request $request)
    {
        foreach ($this->config->getOperators() as $name) {
            $operator = $this->getOperator($name);

            if ($operator->hasToken($request)) {
                return $operator->fetchToken($request);
            }
        }

        return null;
    }
1085923
public function handle($request, Closure $next)
    {
        $response = $next($request);

        // verify only if token present
        if ($token = $this->auth->setRequest($request)->getToken()) {
            // valid for refresh
            if (is_jwt_token_valid_for_refresh($token)) {
                $newToken = refresh_jwt_token();
                if (!empty($newToken)) {
                    // send the refreshed token back to the client
                    $response->headers->set('Authorization', $newToken);
                }
            }
        }

        return $response;
    }
376877
public function start(Request $request, AuthenticationException $authException = null)
    {
        $exception = new MissingTokenException('JWT Token not found', 0, $authException);
        $event     = new JWTNotFoundEvent($exception, new JWTAuthenticationFailureResponse($exception->getMessageKey()));

        if ($this->dispatcher instanceof ContractsEventDispatcherInterface) {
            $this->dispatcher->dispatch($event, Events::JWT_NOT_FOUND);
        } else {
            $this->dispatcher->dispatch(Events::JWT_NOT_FOUND, $event);
        }

        return $event->getResponse();
    }
1149647
public static function initAuth($request) { 
        if($request->getRequiredParameter())
            if(!is_numeric($request->getRequiredParameter()))
                killer('400');
        
        if($request->getRelationalParameter())
            if(!is_numeric($request->getRelationalParameter()))
                killer('400');
        
        if($request->isLogin()) 
            return ServiceAuth::validateAuth($request); 
        if($request->isResetPassword())
            return ServiceAuth::resetPassword($request);
        ServiceAuth::Authenticate($request); 
        return null;
    }
164004
public function onAuthenticationSuccess( Request $request, TokenInterface $token )
	{
		// if AJAX login
		if ( ! $request->isXmlHttpRequest() ) {
			throw new NotFoundHttpException('Must use AJAX Login');
		}

		return new JsonResponse(array(
			"success" => true
		));
	}
307724
public function login(LoginRequest $request, JWTAuth $JWTAuth)
    {
        $credentials = $request->only(['email', 'password']);

        try {
            $token = \JWTAuth::attempt($credentials);

            event(new Login(\JWTAuth::user(), false));

            if (!$token) {
                throw new AccessDeniedHttpException(__('auth.failed'));
            }

        } catch (JWTException $e) {
            throw new HttpException(500);
        }

        return response()
            ->json([
                'status'     => 'ok',
                'token'      => $token,
                'expires_in' => Auth::guard()->factory()->getTTL() * 60
            ]);
    }
711128
public function requestToken(Request $request)
    {
        $client = $this->getClient($request);

        /** @var TokenInterface $accessToken */
        $accessToken = $this->accessTokenRepository->findOneByClientWithoutUser($client);

        if (is_null($accessToken) || $accessToken->isBlocked() || $accessToken->isExpired()) {
            /** @var OrchestraTokenInterface $accessToken */
            $accessToken = $this->accessTokenManager->create($client);
            if (!$accessToken->isValid($this->validator)) {
                return $accessToken->getViolations();
            }

            $this->accessTokenManager->save($accessToken);
        }

        $tokenFacade = new AccessTokenFacade();
        $tokenFacade->accessToken   = $accessToken->getCode();
        $tokenFacade->expiresAt     = $accessToken->getExpiredAt();
        $tokenFacade->refreshToken = $accessToken->getRefreshCode();

        return $tokenFacade;
    }
1174521
public function run(Closure $next = null, Request $request = null)
    {
        if (!$next) {
            return;
        }

        $this->generate();
        abort_unless($this->validate($request), 403, 'Token Validation Failed');
        return $next($request);
    }
612633
protected function createEntityForm(Request $request = NULL)
    {
        $form = $this->createForm($this->type, $this->entity);

        return $request ? $form->handleRequest($request) : $form;
    }
1054916
public function fetchRequestToken(&$request)
    {
        $this->getVersion($request);

        $consumer = $this->getConsumer($request);

        // no token required for the initial token request
        $token = null;

        $this->checkSignature($request, $consumer, $token);

        // Rev A change
        $callback = $request->get_parameter('oauth_callback');
        $new_token = $this->data_store->new_request_token($consumer, $callback);

        return $new_token;
    }