本文整理汇总了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);
}
示例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);
}
示例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;
}