当前位置: 首页>>代码示例>>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;未经允许,请勿转载。