/** * Validate the scopes. * * @param $scopes * * @throws \League\OAuth2\Server\Exception\InvalidScopeException */ public function validateScopes($scopes) { if (!empty($scopes) && !$this->authorizer->hasScope($scopes)) { return false; } return true; }
/** * Validate the scopes * @throws \League\OAuth2\Server\Exception\InvalidScopeException */ public function validateScopes() { if (!empty($this->scopes) and !$this->authorizer->hasScope($this->scopes)) { throw new InvalidScopeException(implode(',', $this->scopes)); } }
/** * Check if the current request has all the scopes passed. * * @param string|array $scope the scope(s) to check for existence * @return bool * @static */ public static function hasScope($scope) { return \LucaDegasperi\OAuth2Server\Authorizer::hasScope($scope); }
function it_passes_with_valud_scopes(Authorizer $authorizer) { $authorizer->validateAccessToken(false)->willReturn('foo')->shouldBeCalled(); $authorizer->hasScope(['baz'])->willReturn(true)->shouldBeCalled(); $this->filter('foo', 'bar', 'baz')->shouldReturn(null); }
/** * Validate the scopes * @throws \League\OAuth2\Server\Exception\InvalidScopeException */ protected function validateScopes() { if (!empty($this->requiredScopes()) and !$this->authorizer->hasScope($this->requiredScopes())) { throw new InvalidScopeException(implode(',', $this->requiredScopes())); } }