@@ -445,7 +445,7 @@ |
||
445 | 445 | { |
446 | 446 | $getter = 'get'.ucfirst($this->snakeToCamel($offset)); |
447 | 447 | $result = $this->{$getter}(); |
448 | - if(is_object($result)) { |
|
448 | + if (is_object($result)) { |
|
449 | 449 | return json_encode($result); |
450 | 450 | } |
451 | 451 | return $result; |
@@ -142,22 +142,22 @@ |
||
142 | 142 | function jsonSerialize() |
143 | 143 | { |
144 | 144 | $data = []; |
145 | - if($this->formatted) { |
|
145 | + if ($this->formatted) { |
|
146 | 146 | $data['formatted'] = $this->formatted; |
147 | 147 | } |
148 | - if($this->streetAddress) { |
|
148 | + if ($this->streetAddress) { |
|
149 | 149 | $data['street_address'] = $this->streetAddress; |
150 | 150 | } |
151 | - if($this->locality) { |
|
151 | + if ($this->locality) { |
|
152 | 152 | $data['locality'] = $this->locality; |
153 | 153 | } |
154 | - if($this->region) { |
|
154 | + if ($this->region) { |
|
155 | 155 | $data['region'] = $this->region; |
156 | 156 | } |
157 | - if($this->postalCode) { |
|
157 | + if ($this->postalCode) { |
|
158 | 158 | $data['postal_code'] = $this->postalCode; |
159 | 159 | } |
160 | - if($this->country) { |
|
160 | + if ($this->country) { |
|
161 | 161 | $data['country'] = $this->country; |
162 | 162 | } |
163 | 163 | return empty($data) ? '' : json_encode($data); |
@@ -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, |
@@ -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]; |
@@ -34,10 +34,10 @@ discard block |
||
34 | 34 | public function __construct(array $storages) |
35 | 35 | { |
36 | 36 | foreach (static::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]; |
@@ -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; |
@@ -53,7 +53,7 @@ |
||
53 | 53 | if (!$this->scopePolicyManager->checkScope($client, $scope)) { |
54 | 54 | $supportedScopes = implode(', ', $this->scopePolicyManager->getSupportedScopes($client)); |
55 | 55 | throw new OAuthException('invalid_scope', |
56 | - 'Some of requested scopes are not supported. Scope supported : ' . $supportedScopes, |
|
56 | + 'Some of requested scopes are not supported. Scope supported : '.$supportedScopes, |
|
57 | 57 | 'https://tools.ietf.org/html/rfc6749#section-4.1'); |
58 | 58 | } |
59 | 59 |
@@ -65,18 +65,18 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | $refreshToken = $request->getParsedBody()['refresh_token'] ?? ''; |
68 | - if(!$refreshToken) { |
|
68 | + if (!$refreshToken) { |
|
69 | 69 | throw new OAuthException('invalid_request', 'Missing a required parameter : refresh_token', |
70 | 70 | 'https://tools.ietf.org/html/rfc6749#section-4.3'); |
71 | 71 | } |
72 | 72 | |
73 | 73 | $refreshToken = $this->refreshTokenStorage->get($refreshToken); |
74 | - if(!$refreshToken || $refreshToken->getClientId() !== $client->getIdentifier()) { |
|
74 | + if (!$refreshToken || $refreshToken->getClientId() !== $client->getIdentifier()) { |
|
75 | 75 | throw new OAuthException('invalid_grant', 'Refresh token is invalid', |
76 | 76 | 'https://tools.ietf.org/html/rfc6749#section-4.3'); |
77 | 77 | } |
78 | 78 | |
79 | - if(!is_null($refreshToken->getExpiresAt()) && $refreshToken->getExpiresAt() < time()) { |
|
79 | + if (!is_null($refreshToken->getExpiresAt()) && $refreshToken->getExpiresAt() < time()) { |
|
80 | 80 | $this->refreshTokenStorage->revoke($refreshToken->getToken()); |
81 | 81 | |
82 | 82 | throw new OAuthException('invalid_grant', 'Refresh token has expired', |
@@ -84,16 +84,16 @@ discard block |
||
84 | 84 | } |
85 | 85 | |
86 | 86 | $includedScopes = isset($request->getParsedBody()['scope']) ? explode(' ', $request->getParsedBody()['scope']) : null; |
87 | - if(is_array($includedScopes) && !empty(array_diff($includedScopes, explode(' ', $refreshToken->getToken())))) { |
|
87 | + if (is_array($includedScopes) && !empty(array_diff($includedScopes, explode(' ', $refreshToken->getToken())))) { |
|
88 | 88 | throw new OAuthException('invalid_scope', |
89 | - 'Some of scope included are not granted for this token. Scope granted : ' . $refreshToken->getScope(), |
|
89 | + 'Some of scope included are not granted for this token. Scope granted : '.$refreshToken->getScope(), |
|
90 | 90 | 'https://tools.ietf.org/html/rfc6749#section-6'); |
91 | 91 | } |
92 | 92 | |
93 | 93 | // issue an access token token and, optionally, a refresh token |
94 | 94 | $accessToken = $this->accessTokenStorage->create($client->getIdentifier(), $refreshToken->getUserId(), $refreshToken->getScope()); |
95 | 95 | $newRefreshToken = null; |
96 | - if($this->configurationRepository->getConfig(Config::REGENERATE_REFRESH_TOKENS_AFTER_USE)) { |
|
96 | + if ($this->configurationRepository->getConfig(Config::REGENERATE_REFRESH_TOKENS_AFTER_USE)) { |
|
97 | 97 | $this->refreshTokenStorage->revoke($refreshToken->getToken()); |
98 | 98 | $newRefreshToken = $this->refreshTokenStorage->create( |
99 | 99 | $refreshToken->getClientId(), $refreshToken->getUserId(), $refreshToken->getScope())->getToken(); |
@@ -63,14 +63,14 @@ discard block |
||
63 | 63 | 'https://tools.ietf.org/html/rfc6749#section-5.2'); |
64 | 64 | } |
65 | 65 | |
66 | - $username= $request->getParsedBody()['username'] ?? ''; |
|
67 | - if(!$username) { |
|
66 | + $username = $request->getParsedBody()['username'] ?? ''; |
|
67 | + if (!$username) { |
|
68 | 68 | throw new OAuthException('invalid_request', 'Missing a required parameter : username', |
69 | 69 | 'https://tools.ietf.org/html/rfc6749#section-4.3'); |
70 | 70 | } |
71 | 71 | |
72 | - $password= $request->getParsedBody()['password'] ?? ''; |
|
73 | - if(!$password) { |
|
72 | + $password = $request->getParsedBody()['password'] ?? ''; |
|
73 | + if (!$password) { |
|
74 | 74 | throw new OAuthException('invalid_request', 'Missing a required parameter : password', |
75 | 75 | 'https://tools.ietf.org/html/rfc6749#section-4.3'); |
76 | 76 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | if (!$this->scopePolicyManager->checkScope($client, $scope)) { |
80 | 80 | $supportedScopes = implode(', ', $this->scopePolicyManager->getSupportedScopes($client)); |
81 | 81 | throw new OAuthException('invalid_scope', |
82 | - 'Some of requested scopes are not supported. Scope supported : ' . $supportedScopes, |
|
82 | + 'Some of requested scopes are not supported. Scope supported : '.$supportedScopes, |
|
83 | 83 | 'https://tools.ietf.org/html/rfc6749#section-4.1'); |
84 | 84 | } |
85 | 85 |