@@ -31,7 +31,7 @@ |
||
| 31 | 31 | * @return array |
| 32 | 32 | */ |
| 33 | 33 | public function handle(ServerRequestInterface $request, ResourceOwnerInterface $resourceOwner, |
| 34 | - RegisteredClient $client, ?array $scope = null): array |
|
| 34 | + RegisteredClient $client, ?array $scope = null): array |
|
| 35 | 35 | { |
| 36 | 36 | |
| 37 | 37 | } |
@@ -19,12 +19,12 @@ |
||
| 19 | 19 | public function __construct(array $claims) |
| 20 | 20 | { |
| 21 | 21 | $missingClaims = array_diff(self::REQUIRED_CLAIMS, array_keys($claims)); |
| 22 | - if(!empty($missingClaims)) { |
|
| 22 | + if (!empty($missingClaims)) { |
|
| 23 | 23 | throw new \Exception('Missing claims : '.implode(', ', $missingClaims)); |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | $undefinedClaims = array_diff(array_keys($claims), self::DEFINED_CLAIMS); |
| 27 | - if(!empty($undefinedClaims)) { |
|
| 27 | + if (!empty($undefinedClaims)) { |
|
| 28 | 28 | throw new \Exception('Undefined claims : '.implode(', ', $undefinedClaims)); |
| 29 | 29 | } |
| 30 | 30 | |
@@ -67,13 +67,13 @@ |
||
| 67 | 67 | foreach (explode(' ', $data['response_type']) as $responseTypeName) { |
| 68 | 68 | $responseType = $this->server->getResponseTypeRepository()->getResponseType($responseTypeName); |
| 69 | 69 | if (!$responseType) { |
| 70 | - throw new OAuthException('invalid_request', 'Unknown response_type : ' . $responseTypeName); |
|
| 70 | + throw new OAuthException('invalid_request', 'Unknown response_type : '.$responseTypeName); |
|
| 71 | 71 | } |
| 72 | 72 | $responseType->verifyRequest($request); |
| 73 | 73 | $responseTypes[] = $responseType; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - if(empty($responseTypes)) { |
|
| 76 | + if (empty($responseTypes)) { |
|
| 77 | 77 | throw new OAuthException('invalid_request', 'Invalid response_type parameter'); |
| 78 | 78 | } |
| 79 | 79 | else if (count($responseTypes) == 1) { |
@@ -75,8 +75,7 @@ |
||
| 75 | 75 | |
| 76 | 76 | if(empty($responseTypes)) { |
| 77 | 77 | throw new OAuthException('invalid_request', 'Invalid response_type parameter'); |
| 78 | - } |
|
| 79 | - else if (count($responseTypes) == 1) { |
|
| 78 | + } else if (count($responseTypes) == 1) { |
|
| 80 | 79 | $defaultResponseMode = $responseTypes[0]->getDefaultResponseMode(); |
| 81 | 80 | } else { |
| 82 | 81 | $defaultResponseMode = ResponseTypeInterface::RESPONSE_MODE_FRAGMENT; |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | $grantType = $this->server->getGrantTypeRepository()->getGrantType($grantTypeName); |
| 37 | 37 | if (!$grantType) { |
| 38 | 38 | return new ErrorResponse('unsupported_grant_type', |
| 39 | - 'Unsupported grant type : ' . $grantTypeName, |
|
| 39 | + 'Unsupported grant type : '.$grantTypeName, |
|
| 40 | 40 | 'https://tools.ietf.org/html/rfc6749#section-5.2'); |
| 41 | 41 | } |
| 42 | 42 | |
@@ -54,18 +54,18 @@ discard block |
||
| 54 | 54 | } catch (OAuthException $e) { |
| 55 | 55 | if ($e->getError() == 'invalid_client' && $request->hasHeader('Authorization')) { |
| 56 | 56 | return new ErrorResponse($e->getError(), |
| 57 | - 'Client authentication failed : ' . $e->getMessage(), |
|
| 57 | + 'Client authentication failed : '.$e->getMessage(), |
|
| 58 | 58 | $e->getErrorUri(), 401, [ |
| 59 | 59 | 'WWW-Authenticate' => 'Basic' |
| 60 | 60 | ]); |
| 61 | 61 | } else { |
| 62 | 62 | return new ErrorResponse($e->getError(), |
| 63 | - 'Client authentication failed : ' . $e->getMessage(), |
|
| 63 | + 'Client authentication failed : '.$e->getMessage(), |
|
| 64 | 64 | $e->getErrorUri(), 401); |
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - if(!$client) { |
|
| 68 | + if (!$client) { |
|
| 69 | 69 | if (!isset($request->getParsedBody()['client_id'])) { |
| 70 | 70 | return new ErrorResponse('invalid_request', |
| 71 | 71 | 'Client authentication not included, missing a parameter : client_id : ', |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | if ($client->hasCredentials()) { |
| 83 | 83 | return new ErrorResponse('invalid_client', |
| 84 | - 'Client authentication failed : ' . $guard->getError(), |
|
| 84 | + 'Client authentication failed : '.$guard->getError(), |
|
| 85 | 85 | 'https://tools.ietf.org/html/rfc6749#section-5.2', 401, [ |
| 86 | 86 | 'WWW-Authenticate' => 'Basic' |
| 87 | 87 | ]); |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | |
| 91 | 91 | if (is_array($client->getSupportedGrantTypes()) && !in_array($grantType->getUri(), $client->getSupportedGrantTypes())) { |
| 92 | 92 | return new ErrorResponse('unauthorized_client', |
| 93 | - 'Unauthorized grant type : ' . $grantType->getUri(), |
|
| 93 | + 'Unauthorized grant type : '.$grantType->getUri(), |
|
| 94 | 94 | 'https://tools.ietf.org/html/rfc6749#section-5.2'); |
| 95 | 95 | } |
| 96 | 96 | |
@@ -96,8 +96,7 @@ |
||
| 96 | 96 | |
| 97 | 97 | try { |
| 98 | 98 | return $grantType->grant($request, $client); |
| 99 | - } |
|
| 100 | - catch (OAuthException $e) { |
|
| 99 | + } catch (OAuthException $e) { |
|
| 101 | 100 | return new ErrorResponse($e->getError(), |
| 102 | 101 | $e->getErrorDescription(), |
| 103 | 102 | $e->getErrorUri()); |
@@ -29,7 +29,7 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | public function __construct(array $authenticators) |
| 31 | 31 | { |
| 32 | - if(!isset($authenticators[ClientPasswordAuthenticator::class])) { |
|
| 32 | + if (!isset($authenticators[ClientPasswordAuthenticator::class])) { |
|
| 33 | 33 | throw new \Exception('Authorization server MUST support the HTTP Basic authentication scheme'); |
| 34 | 34 | } |
| 35 | 35 | $this->authenticators = $authenticators; |
@@ -34,10 +34,10 @@ discard block |
||
| 34 | 34 | public function __construct(array $storages) |
| 35 | 35 | { |
| 36 | 36 | foreach (self::STORAGES_INTERFACES as $name => $interface) { |
| 37 | - if(!isset($storages[$name])) { |
|
| 37 | + if (!isset($storages[$name])) { |
|
| 38 | 38 | throw new \Exception("Missing storage '$name'"); |
| 39 | 39 | } |
| 40 | - if(!is_a($storages[$name], $interface)) { |
|
| 40 | + if (!is_a($storages[$name], $interface)) { |
|
| 41 | 41 | throw new \Exception("Storage '$name' must implement '$interface'"); |
| 42 | 42 | } |
| 43 | 43 | $this->storages[$name] = $storages[$name]; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | * @throws \Exception |
| 51 | 51 | */ |
| 52 | 52 | public function getStorage(string $name) { |
| 53 | - if(!isset($this->storages[$name])) { |
|
| 53 | + if (!isset($this->storages[$name])) { |
|
| 54 | 54 | throw new \Exception("Unknown storage '$name'"); |
| 55 | 55 | } |
| 56 | 56 | return $this->storages[$name]; |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | public function __construct(array $config = []) |
| 41 | 41 | { |
| 42 | 42 | if (array_diff(self::MINIMAL_CONFIG, array_keys($config))) { |
| 43 | - throw new \Exception('Missing minimal configuration. Required : ' . implode(', ', self::MINIMAL_CONFIG)); |
|
| 43 | + throw new \Exception('Missing minimal configuration. Required : '.implode(', ', self::MINIMAL_CONFIG)); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | $this->config = array_merge(self::DEFAULT_CONFIG, $config); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | * @throws \Exception |
| 53 | 53 | */ |
| 54 | 54 | public function getConfig(string $name) { |
| 55 | - if(!array_key_exists($name, $this->config)) { |
|
| 55 | + if (!array_key_exists($name, $this->config)) { |
|
| 56 | 56 | throw new \Exception("Unknown config '$name' in ".implode(', ', array_keys($this->config))); |
| 57 | 57 | } |
| 58 | 58 | return $this->config[$name]; |
@@ -75,7 +75,7 @@ |
||
| 75 | 75 | $clientCredentialsGrantType = new ClientCredentialsGrantType($scopePolicyManager, $accessTokenStorage); |
| 76 | 76 | $resourceOwnerPasswordCredentialsGrantType = new ResourceOwnerPasswordCredentialsGrantType( |
| 77 | 77 | $resourceOwnerProvider, $scopePolicyManager, $accessTokenStorage, $refreshTokenStorage); |
| 78 | - $refreshTokenGrantType = new RefreshTokenGrantType($configurationRepository , $scopePolicyManager, $accessTokenStorage, $refreshTokenStorage); |
|
| 78 | + $refreshTokenGrantType = new RefreshTokenGrantType($configurationRepository, $scopePolicyManager, $accessTokenStorage, $refreshTokenStorage); |
|
| 79 | 79 | return [ |
| 80 | 80 | $authorizationCodeGrantType->getUri() => $authorizationCodeGrantType, |
| 81 | 81 | $clientCredentialsGrantType->getUri() => $clientCredentialsGrantType, |
@@ -14,5 +14,5 @@ |
||
| 14 | 14 | interface ScopePolicyInterface |
| 15 | 15 | { |
| 16 | 16 | // function check(array $scope, ClientInterface $client): bool ; |
| 17 | - function getDefaultScopes(ClientInterface $client) : ?array ; |
|
| 17 | + function getDefaultScopes(ClientInterface $client) : ?array; |
|
| 18 | 18 | } |
| 19 | 19 | \ No newline at end of file |