scopes() 공개 메소드

Get the route scopes.
public scopes ( ) : array
리턴 array
예제 #1
0
 public function testControllerOptionsMergeAndOverrideRouteOptions()
 {
     $request = Request::create('foo', 'GET');
     $route = new Route($this->adapter, $this->container, $request, ['uri' => 'foo', 'methods' => ['GET', 'HEAD'], 'action' => ['scopes' => ['foo', 'bar'], 'providers' => ['foo'], 'limit' => 5, 'expires' => 10, 'throttle' => 'Foo', 'version' => ['v1'], 'conditionalRequest' => false, 'uses' => 'Dingo\\Api\\Tests\\Stubs\\RoutingControllerStub@index']]);
     $this->assertEquals(['foo', 'bar', 'baz', 'bing'], $route->scopes(), 'Route did not setup scopes correctly.');
     $this->assertEquals(['foo', 'red', 'black'], $route->getAuthProviders(), 'Route did not setup authentication providers correctly.');
     $this->assertEquals(10, $route->getRateLimit(), 'Route did not setup rate limit correctly.');
     $this->assertEquals(20, $route->getRateExpiration(), 'Route did not setup rate limit expiration correctly.');
     $this->assertTrue($route->hasThrottle(), 'Route did not setup throttle correctly.');
     $this->assertInstanceOf('Dingo\\Api\\Tests\\Stubs\\BasicThrottleStub', $route->getThrottle(), 'Route did not setup throttle correctly.');
 }
예제 #2
0
 /**
  * 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
0
파일: OAuth2.php 프로젝트: jieke360/api
 /**
  * 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;
 }