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


PHP AccessTokenEntity::hasScope方法代碼示例

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


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

示例1:

 function it_checks_if_multiple_valid_scopes_are_included_into_the_current_ones(ResourceServer $checker, AccessTokenEntity $accessTokenEntity)
 {
     $accessTokenEntity->hasScope('foo')->willReturn(true)->shouldBecalled();
     $accessTokenEntity->hasScope('bar')->willReturn(true)->shouldBeCalled();
     $checker->getAccessToken()->willReturn($accessTokenEntity)->shouldBeCalledTimes(2);
     $this->hasScope(['foo', 'bar'])->shouldReturn(true);
 }
開發者ID:nikitgs,項目名稱:oauth2-server-laravel,代碼行數:7,代碼來源:AuthorizerSpec.php

示例2: validateRouteScopes

 /**
  * Validate a routes scopes.
  *
  * @param \League\OAuth2\Server\Entity\AccessTokenEntity $token
  * @param \Dingo\Api\Routing\Route                       $route
  *
  * @throws \League\OAuth2\Server\Exception\InvalidScopeException
  *
  * @return bool
  */
 protected function validateRouteScopes(AccessTokenEntity $token, Route $route)
 {
     $scopes = $route->scopes();
     if (empty($scopes)) {
         return true;
     }
     foreach ($scopes as $scope) {
         if ($token->hasScope($scope)) {
             return true;
         }
     }
     throw new InvalidScopeException($scope);
 }
開發者ID:leloulight,項目名稱:laravel_dingo_oauth2,代碼行數:23,代碼來源:OAuth2.php

示例3: validateAllRouteScopes

 /**
  * Validate a route has all scopes.
  *
  * @param \League\OAuth2\Server\Entity\AccessTokenEntity $token
  * @param \Dingo\Api\Routing\Route                       $route
  *
  * @throws \League\OAuth2\Server\Exception\InvalidScopeException
  *
  * @return bool
  */
 protected function validateAllRouteScopes(AccessTokenEntity $token, Route $route)
 {
     $scopes = $route->scopes();
     foreach ($scopes as $scope) {
         if (!$token->hasScope($scope)) {
             throw new InvalidScopeException($scope);
         }
     }
     return true;
 }
開發者ID:jieke360,項目名稱:api,代碼行數:20,代碼來源:OAuth2.php


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