Passed
Push — master ( 411f65...7cec5a )
by Alexandre
02:03
created
src/OAuth2OLD/Repositories/ClientAuthenticatorRepository.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/OAuth2OLD/GrantTypes/ClientCredentialsGrantType.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/OAuth2OLD/GrantTypes/RefreshTokenGrantType.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -65,18 +65,18 @@  discard block
 block discarded – undo
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
 block discarded – undo
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();
Please login to merge, or discard this patch.
src/OAuth2OLD/GrantTypes/ResourceOwnerPasswordCredentialsGrantType.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -85,8 +85,7 @@
 block discarded – undo
85 85
 
86 86
         try {
87 87
             $resourceOwner = $this->resourceOwnerProvider->authenticate($username, $password);
88
-        }
89
-        catch (\Exception $e) {
88
+        } catch (\Exception $e) {
90 89
             throw new OAuthException('invalid_grant', $e->getMessage(),
91 90
                 'https://tools.ietf.org/html/rfc6749#section-4.3');
92 91
         }
Please login to merge, or discard this patch.
src/OAuth2OLD/GrantTypes/AuthorizationCodeGrantType.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@
 block discarded – undo
73 73
 
74 74
         $this->authorizationCodeStorage->revoke($authorizationCode->getCode());
75 75
 
76
-        if($authorizationCode->getExpiresAt() < time()) {
76
+        if ($authorizationCode->getExpiresAt() < time()) {
77 77
             throw new OAuthException('invalid_grant', 'Authorization code has expired',
78 78
                 'https://tools.ietf.org/html/rfc6749#section-4.1.3');
79 79
         }
Please login to merge, or discard this patch.
src/OAuth2/Endpoints/AuthorizationEndpoint.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -212,7 +212,7 @@
 block discarded – undo
212 212
         }
213 213
         else {
214 214
             if (count($redirectUris) == 1) {
215
-               $redirectUri = $redirectUris[0];
215
+                $redirectUri = $redirectUris[0];
216 216
             }
217 217
             else {
218 218
                 throw new OAuthException('invalid_request', 'The request is missing the required parameter redirect_uri.',
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -124,15 +124,15 @@  discard block
 block discarded – undo
124 124
             $responseData = [
125 125
                 'error' => $e->getError()
126 126
             ];
127
-            if($e->getErrorDescription()) {
127
+            if ($e->getErrorDescription()) {
128 128
                 $responseData['error_description'] = $e->getErrorDescription();
129 129
             }
130
-            if($e->getErrorUri()) {
130
+            if ($e->getErrorUri()) {
131 131
                 $responseData['error_uri'] = $e->getErrorUri();
132 132
             }
133 133
         }
134 134
 
135
-        if(!empty($this->state)) {
135
+        if (!empty($this->state)) {
136 136
             $responseData['state'] = $this->state;
137 137
         }
138 138
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
         $supportedResponseTypes = $this->client->getMetadata()->getResponseTypes() ?: ['code'];
173 173
         foreach (explode(' ', $requestData['response_type']) as $responseType) {
174
-            if(!in_array($responseType, $supportedResponseTypes)) {
174
+            if (!in_array($responseType, $supportedResponseTypes)) {
175 175
             throw new OAuthException('unsupported_response_type',
176 176
                 'The authorization server does not support obtaining an authorization code using this method.',
177 177
                 'https://tools.ietf.org/html/rfc6749#section-4.1');
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
         }
220 220
         try {
221 221
             $redirectUri = new Uri($redirectUri);
222
-            if($redirectUri->getFragment()) {
222
+            if ($redirectUri->getFragment()) {
223 223
                 throw new \InvalidArgumentException('The endpoint URI must not include a fragment component.');
224 224
             }
225 225
             $this->redirectUri = $redirectUri;
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -207,12 +207,10 @@  discard block
 block discarded – undo
207 207
                 throw new OAuthException('invalid_request', 'The request includes the invalid parameter redirect_uri.',
208 208
                     'https://tools.ietf.org/html/rfc6749#section-4.1');
209 209
             }
210
-        }
211
-        else {
210
+        } else {
212 211
             if (count($redirectUris) == 1) {
213 212
                $redirectUri = $redirectUris[0];
214
-            }
215
-            else {
213
+            } else {
216 214
                 throw new OAuthException('invalid_request', 'The request is missing the required parameter redirect_uri.',
217 215
                     'https://tools.ietf.org/html/rfc6749#section-4.1');
218 216
             }
@@ -223,8 +221,7 @@  discard block
 block discarded – undo
223 221
                 throw new \InvalidArgumentException('The endpoint URI must not include a fragment component.');
224 222
             }
225 223
             $this->redirectUri = $redirectUri;
226
-        }
227
-        catch (\InvalidArgumentException $e) {
224
+        } catch (\InvalidArgumentException $e) {
228 225
             throw new OAuthException('invalid_request', 'The request includes the malformed parameter redirect_uri. '.$e->getMessage(),
229 226
                 'https://tools.ietf.org/html/rfc6749#section-4.1');
230 227
         }
Please login to merge, or discard this patch.
src/OAuth2/ScopePolicy/ScopePolicyManager.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function verifyScopes(ClientInterface $client, array $scopes): void
51 51
     {
52
-        if(empty($scopes)) {
52
+        if (empty($scopes)) {
53 53
             throw new OAuthException('invalid_scope',
54 54
                 'The request scope is unknown.',
55 55
                 'https://tools.ietf.org/html/rfc6749#section-4.1');
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 
58 58
         if ($client instanceof RegisteredClient && is_array($client->getMetadata()->getScope())) {
59 59
             $supportedScopes = explode(' ', $client->getMetadata()->getScope());
60
-            if(!empty(array_diff($scopes, $supportedScopes))) {
60
+            if (!empty(array_diff($scopes, $supportedScopes))) {
61 61
                 throw new OAuthException('invalid_scope',
62 62
                     'The request scope is invalid. Supported scopes : '.$client->getMetadata()->getScope(),
63 63
                     'https://tools.ietf.org/html/rfc6749#section-4.1');
Please login to merge, or discard this patch.