當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Request::bearerToken方法代碼示例

本文整理匯總了PHP中Illuminate\Http\Request::bearerToken方法的典型用法代碼示例。如果您正苦於以下問題:PHP Request::bearerToken方法的具體用法?PHP Request::bearerToken怎麽用?PHP Request::bearerToken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Http\Request的用法示例。


在下文中一共展示了Request::bearerToken方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getTokenForRequest

 /**
  * Get the token for the current request.
  *
  * @return string
  */
 public function getTokenForRequest()
 {
     $token = $this->request->input($this->inputKey);
     if (empty($token)) {
         $token = $this->request->bearerToken();
     }
     return $token;
 }
開發者ID:lucasromanojf,項目名稱:jwt-guard,代碼行數:13,代碼來源:JWTGuardTrait.php

示例2: getTokenForRequest

 /**
  * Get the token for the current request.
  *
  * @return string
  */
 protected function getTokenForRequest()
 {
     $token = $this->request->input($this->inputKey);
     if (empty($token)) {
         $token = $this->request->bearerToken();
     }
     if (empty($token)) {
         $token = $this->request->getPassword();
     }
     return $token;
 }
開發者ID:eugene-holiday,項目名稱:framework,代碼行數:16,代碼來源:TokenGuard.php

示例3: authenticate

 public function authenticate(Request $request, Route $route)
 {
     if (!$request->bearerToken() || empty($request->bearerToken())) {
         throw new UnauthorizedHttpException('The authentication header was missing or malformed');
     }
     list($public, $hashed) = explode('.', $request->bearerToken());
     $key = APIKey::where('public', $public)->first();
     if (!$key) {
         throw new AccessDeniedHttpException('Invalid API Key.');
     }
     // Check for Resource Permissions
     if (!empty($request->route()->getName())) {
         if (!is_null($key->allowed_ips)) {
             $inRange = false;
             foreach (json_decode($key->allowed_ips) as $ip) {
                 if (Range::parse($ip)->contains(new IP($request->ip()))) {
                     $inRange = true;
                     break;
                 }
             }
             if (!$inRange) {
                 throw new AccessDeniedHttpException('This IP address <' . $request->ip() . '> does not have permission to use this API key.');
             }
         }
         foreach (APIPermission::where('key_id', $key->id)->get() as &$row) {
             if ($row->permission === '*' || $row->permission === $request->route()->getName()) {
                 $this->permissionAllowed = true;
                 continue;
             }
         }
         if (!$this->permissionAllowed) {
             throw new AccessDeniedHttpException('You do not have permission to access this resource.');
         }
     }
     try {
         $decrypted = Crypt::decrypt($key->secret);
     } catch (\Illuminate\Contracts\Encryption\DecryptException $ex) {
         throw new HttpException('There was an error while attempting to check your secret key.');
     }
     $this->url = urldecode($request->fullUrl());
     if ($this->_generateHMAC($request->getContent(), $decrypted) !== base64_decode($hashed)) {
         throw new BadRequestHttpException('The hashed body was not valid. Potential modification of contents in route.');
     }
     return true;
 }
開發者ID:Pterodactyl,項目名稱:Panel,代碼行數:45,代碼來源:APISecretToken.php

示例4: getTokenFromRequest

 /**
  * Get the token for the given request.
  *
  * @param  Request  $request
  * @return Token|string
  */
 protected function getTokenFromRequest(Request $request)
 {
     $bearer = $request->bearerToken();
     // First we will check to see if the token is in the request input data or is a bearer
     // token on the request. If it is, we will consider this the token, otherwise we'll
     // look for the token in the cookies then attempt to validate that it is correct.
     if ($token = $request->input('api_token', $bearer)) {
         return $token;
     }
     if ($request->cookie('kodicms_token')) {
         return $this->getTokenFromCookie($request);
     }
 }
開發者ID:KodiComponents,項目名稱:module-api,代碼行數:19,代碼來源:TokenGuard.php

示例5: getTokenForRequest

 /**
  * Get the token for the current request.
  *
  * @return \Lcobucci\JWT\Token
  */
 protected function getTokenForRequest()
 {
     $token = $this->request->bearerToken();
     if (empty($token)) {
         return null;
     }
     try {
         $token = (new Parser())->parse($token);
         if (!$this->signer->verify($token)) {
             return null;
         }
     } catch (InvalidArgumentException $e) {
         return null;
     }
     return $token;
 }
開發者ID:framgia,項目名稱:laravel-jwt,代碼行數:21,代碼來源:Guard.php

示例6: isAuthenticated

 public function isAuthenticated(Request $request)
 {
     $token = $request->bearerToken();
     if (null === $token) {
         $token = $request->cookie(config('stormpath.web.accessTokenCookie.name'));
     }
     if ($token instanceof \Symfony\Component\HttpFoundation\Cookie) {
         $token = $token->getValue();
     }
     try {
         (new \Stormpath\Oauth\VerifyAccessToken(app('stormpath.application')))->verify($token);
         return true;
     } catch (\Exception $re) {
         return false;
     }
 }
開發者ID:stormpath,項目名稱:stormpath-laravel,代碼行數:16,代碼來源:Authenticate.php

示例7: handle

 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     if (!($token = $request->bearerToken())) {
         throw new InvalidTokenAuthorizationHeader();
     }
     // Validate the vadility of the token
     try {
         $payload = $this->manager->setRefreshFlow($this->getRefreshFlow())->decode(new Token($token));
     } catch (\Exception $e) {
         throw new InvalidToken();
     }
     if (!$this->auth->onceUsingId($payload->get('sub'))) {
         throw new InvalidUser();
     }
     return $next($request);
 }
開發者ID:devdk,項目名稱:signy,代碼行數:24,代碼來源:ValidateToken.php

示例8: bearerToken

 /**
  * Get the bearer token from the request headers.
  *
  * @return string|null 
  * @static 
  */
 public static function bearerToken()
 {
     return \Illuminate\Http\Request::bearerToken();
 }
開發者ID:andybolano,項目名稱:viaja_seguro,代碼行數:10,代碼來源:_ide_helper.php


注:本文中的Illuminate\Http\Request::bearerToken方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。