Passed
Push — master ( a8d522...c97e91 )
by Alexandre
02:40
created
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   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -85,10 +85,10 @@  discard block
 block discarded – undo
85 85
 
86 86
     function handleRequest(ServerRequestInterface $request): ResponseInterface
87 87
     {
88
-        if($request->getMethod() === 'GET') {
88
+        if ($request->getMethod() === 'GET') {
89 89
             $requestData = $request->getQueryParams();
90 90
         }
91
-        else if($request->getMethod() === 'POST') {
91
+        else if ($request->getMethod() === 'POST') {
92 92
             $requestData = $request->getParsedBody();
93 93
         }
94 94
         else {
@@ -132,15 +132,15 @@  discard block
 block discarded – undo
132 132
             $responseData = [
133 133
                 'error' => $e->getError()
134 134
             ];
135
-            if($e->getErrorDescription()) {
135
+            if ($e->getErrorDescription()) {
136 136
                 $responseData['error_description'] = $e->getErrorDescription();
137 137
             }
138
-            if($e->getErrorUri()) {
138
+            if ($e->getErrorUri()) {
139 139
                 $responseData['error_uri'] = $e->getErrorUri();
140 140
             }
141 141
         }
142 142
 
143
-        if(!empty($this->state)) {
143
+        if (!empty($this->state)) {
144 144
             $responseData['state'] = $this->state;
145 145
         }
146 146
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 
180 180
         $supportedResponseTypes = $this->client->getMetadata()->getResponseTypes() ?: ['code'];
181 181
         foreach (explode(' ', $requestData['response_type']) as $responseType) {
182
-            if(!in_array($responseType, $supportedResponseTypes)) {
182
+            if (!in_array($responseType, $supportedResponseTypes)) {
183 183
             throw new OAuthException('unsupported_response_type',
184 184
                 'The authorization server does not support obtaining an authorization code using this method.',
185 185
                 'https://tools.ietf.org/html/rfc6749#section-4.1');
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
         }
228 228
         try {
229 229
             $redirectUri = new Uri($redirectUri);
230
-            if($redirectUri->getFragment()) {
230
+            if ($redirectUri->getFragment()) {
231 231
                 throw new \InvalidArgumentException('The endpoint URI must not include a fragment component.');
232 232
             }
233 233
             $this->redirectUri = $redirectUri;
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -87,11 +87,9 @@  discard block
 block discarded – undo
87 87
     {
88 88
         if($request->getMethod() === 'GET') {
89 89
             $requestData = $request->getQueryParams();
90
-        }
91
-        else if($request->getMethod() === 'POST') {
90
+        } else if($request->getMethod() === 'POST') {
92 91
             $requestData = $request->getParsedBody();
93
-        }
94
-        else {
92
+        } else {
95 93
             return new Response(404);
96 94
         }
97 95
 
@@ -215,12 +213,10 @@  discard block
 block discarded – undo
215 213
                 throw new OAuthException('invalid_request', 'The request includes the invalid parameter redirect_uri.',
216 214
                     'https://tools.ietf.org/html/rfc6749#section-4.1');
217 215
             }
218
-        }
219
-        else {
216
+        } else {
220 217
             if (count($redirectUris) == 1) {
221 218
                $redirectUri = $redirectUris[0];
222
-            }
223
-            else {
219
+            } else {
224 220
                 throw new OAuthException('invalid_request', 'The request is missing the required parameter redirect_uri.',
225 221
                     'https://tools.ietf.org/html/rfc6749#section-4.1');
226 222
             }
@@ -231,8 +227,7 @@  discard block
 block discarded – undo
231 227
                 throw new \InvalidArgumentException('The endpoint URI must not include a fragment component.');
232 228
             }
233 229
             $this->redirectUri = $redirectUri;
234
-        }
235
-        catch (\InvalidArgumentException $e) {
230
+        } catch (\InvalidArgumentException $e) {
236 231
             throw new OAuthException('invalid_request', 'The request includes the malformed parameter redirect_uri. '.$e->getMessage(),
237 232
                 'https://tools.ietf.org/html/rfc6749#section-4.1');
238 233
         }
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.
src/OAuth2/Extensions/OpenID/Endpoints/AuthorizationEndpoint.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
              */
48 48
             $scope = $requestData['scope'] ?? '';
49 49
             $scopes = explode(' ', $scope);
50
-            if(!in_array('openid', $scopes)) {
50
+            if (!in_array('openid', $scopes)) {
51 51
                 return parent::handleRequest($request);
52 52
             }
53 53
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -121,8 +121,7 @@
 block discarded – undo
121 121
              * specified in the Authorization Request using the application/x-www-form-urlencoded format,
122 122
              * unless a different Response Mode was specified.
123 123
              */
124
-        }
125
-        catch (OAuthException $e) {
124
+        } catch (OAuthException $e) {
126 125
             /**
127 126
              * If the Authorization Server encounters any error, it MUST return an error response, per Section 3.1.2.6.
128 127
              */
Please login to merge, or discard this patch.
src/OAuth2/Extensions/PKCE/Credentials/AuthorizationCode.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
                                 int $expiresAt, ?string $requestedScope = null, ?string $redirectUri = null,
25 25
                                 ?string $codeChallenge = null, ?string $codeChallengeMethod = null)
26 26
     {
27
-       parent::__construct($code, $scope, $clientIdentifier, $resourceOwnerIdentifier, $expiresAt, $requestedScope, $redirectUri);
27
+        parent::__construct($code, $scope, $clientIdentifier, $resourceOwnerIdentifier, $expiresAt, $requestedScope, $redirectUri);
28 28
         $this->codeChallenge = $codeChallenge;
29 29
         $this->codeChallengeMethod = $codeChallengeMethod;
30 30
     }
Please login to merge, or discard this patch.
src/OAuth2/Endpoints/TokenEndpoint.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -88,9 +88,9 @@
 block discarded – undo
88 88
              */
89 89
             $status = 400;
90 90
             $headers = ['Content-Type' => 'application/json'];
91
-            if($e->getError() === 'invalid_client') {
91
+            if ($e->getError() === 'invalid_client') {
92 92
                 $status = 401;
93
-                    if($request->hasHeader('Authorization')) {
93
+                    if ($request->hasHeader('Authorization')) {
94 94
                         $headers['WWW-Authenticate'] = 'Basic';
95 95
                 }
96 96
             }
Please login to merge, or discard this patch.