Passed
Push — master ( a8d522...c97e91 )
by Alexandre
02:40
created
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.
src/OAuth2/Endpoints/AuthorizationEndpoint.php 2 patches
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/ClientAuthentication/ClientAuthenticationMethodManager.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
          */
43 43
         $clientAuthenticationMethodUsedIdentifier = null;
44 44
         foreach ($this->clientAuthenticationMethods as $identifier => $clientAuthenticationMethod) {
45
-            if($clientAuthenticationMethod->support($request, $requestData))  {
46
-                if($clientAuthenticationMethodUsedIdentifier) {
45
+            if ($clientAuthenticationMethod->support($request, $requestData)) {
46
+                if ($clientAuthenticationMethodUsedIdentifier) {
47 47
                     throw new OAuthException('invalid_request',
48 48
                         'The request utilizes more than one mechanism for authenticating the client.',
49 49
                         'https://tools.ietf.org/html/rfc6749#section-3.2.1');
@@ -52,14 +52,14 @@  discard block
 block discarded – undo
52 52
             }
53 53
         }
54 54
 
55
-        if($clientAuthenticationMethod = $this->clientAuthenticationMethods[$clientAuthenticationMethodUsedIdentifier] ?? null) {
56
-            if(!$client = $clientAuthenticationMethod->authenticate($request, $requestData)) {
55
+        if ($clientAuthenticationMethod = $this->clientAuthenticationMethods[$clientAuthenticationMethodUsedIdentifier] ?? null) {
56
+            if (!$client = $clientAuthenticationMethod->authenticate($request, $requestData)) {
57 57
                 throw new OAuthException('invalid_client',
58 58
                     'Client authentication failed. Unknown client.',
59 59
                     'https://tools.ietf.org/html/rfc6749#section-3.2.1');
60 60
             }
61 61
 
62
-            if($client->getMetadata()->getTokenEndpointAuthMethod())
62
+            if ($client->getMetadata()->getTokenEndpointAuthMethod())
63 63
         } else { // else check client_id parameter
64 64
             if (empty($requestData['client_id'])) {
65 65
                 throw new OAuthException('invalid_request', 'The request is missing the required parameter client_id.',
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
         }
74 74
 
75 75
 
76
-        if($client->hasCredentials()) {
76
+        if ($client->hasCredentials()) {
77 77
             $tokenEndpointAuthMethod = $this->client->getMetadata()->getTokenEndpointAuthMethod() ?: 'client_secret_basic';
78 78
             if (!$clientAuthenticationMethod = $this->clientAuthenticationMethodManager->getClientAuthenticationMethod($tokenEndpointAuthMethod)) {
79 79
                 throw new OAuthException('invalid_client', 'Client authentication failed. Unsupported authentication method',
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -59,12 +59,13 @@
 block discarded – undo
59 59
                     'https://tools.ietf.org/html/rfc6749#section-3.2.1');
60 60
             }
61 61
 
62
-            if($client->getMetadata()->getTokenEndpointAuthMethod())
63
-        } else { // else check client_id parameter
62
+            if($client->getMetadata()->getTokenEndpointAuthMethod()) {
63
+                    } else { // else check client_id parameter
64 64
             if (empty($requestData['client_id'])) {
65 65
                 throw new OAuthException('invalid_request', 'The request is missing the required parameter client_id.',
66 66
                     'https://tools.ietf.org/html/rfc6749#section-4.1');
67 67
             }
68
+            }
68 69
 
69 70
             if (!$client = $this->clientStorage->get($requestData['client_id'])) {
70 71
                 throw new OAuthException('invalid_request', 'The request includes the invalid parameter client_id.',
Please login to merge, or discard this patch.