public function resolve(Context $context)
 {
     if (f\not($context->getScopes()->isEmpty())) {
         return $context;
     }
     $defaultScopes = ScopeCollection::createFromString(f\get($context->getClient(), 'defaultScope'));
     return new Context($context->getClient(), $context->getUserId(), $defaultScopes);
 }
 public function resolve(Context $context)
 {
     $isScopeAllowed = [$context->getClient(), 'hasAllowedScope'];
     $scopeNames = $context->getScopes()->getNames();
     if (f\some(f\not_fn($isScopeAllowed), $scopeNames)) {
         throw new UnauthorizedClientForScopeOAuthErrorException();
     }
     return $context;
 }
Beispiel #3
0
 public function testContext()
 {
     $client = $this->createClient();
     $userId = 'foo';
     $scopes = new ScopeCollection([new Scope('foo')]);
     $context = new Context($client, $userId, $scopes);
     $this->assertSame($client, $context->getClient());
     $this->assertSame($userId, $context->getUserId());
     $this->assertSame($scopes, $context->getScopes());
 }
 public function create(Context $context)
 {
     return new AccessToken(['token' => $this->tokenGenerator->generate(), 'type' => 'bearer', 'clientId' => f\get($context->getClient(), 'id'), 'userId' => $context->getUserId(), 'lifetime' => $this->lifetime, 'scope' => $context->getScopes()->__toString()]);
 }