Completed
Pull Request — master (#7)
by
unknown
01:58
created
src/Auth/Adapter/Oidc.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
     {
205 205
         if($this->token_validation_url) {
206 206
             $this->logger->debug('validate oauth2 token via rfc7662 token validation endpoint ['.$this->token_validation_url.']', [
207
-               'category' => get_class($this),
207
+                'category' => get_class($this),
208 208
             ]);
209 209
 
210 210
             $url = str_replace('{token}', $token, $this->token_validation_url);
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
             }
217 217
 
218 218
             $this->logger->debug('validate token via openid-connect userinfo_endpoint ['.$discovery['userinfo_endpoint'].']', [
219
-               'category' => get_class($this),
219
+                'category' => get_class($this),
220 220
             ]);
221 221
 
222 222
             $url = $discovery['userinfo_endpoint'].'?access_token='.$token;
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
         }
238 238
 
239 239
         $this->logger->error('failed verify oauth2 access token via authorization server, received status ['.$code.']', [
240
-           'category' => get_class($this),
240
+            'category' => get_class($this),
241 241
         ]);
242 242
 
243 243
         return false;
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 
260 260
         if($response['active']) {
261 261
             $this->logger->debug('successfully verified oauth2 access token via authorization server', [
262
-               'category' => get_class($this),
262
+                'category' => get_class($this),
263 263
             ]);
264 264
 
265 265
             if(!isset($response['username'])) {
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
         if ($code === 200) {
288 288
             $attributes = $response;
289 289
             $this->logger->debug('successfully verified oauth2 access token via authorization server', [
290
-               'category' => get_class($this),
290
+                'category' => get_class($this),
291 291
             ]);
292 292
 
293 293
             if(!isset($attributes[$this->identity_attribute])) {
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
         }
322 322
 
323 323
         $this->logger->debug('fetch user attributes from userinfo_endpoint ['.$discovery['userinfo_endpoint'].']', [
324
-           'category' => get_class($this),
324
+            'category' => get_class($this),
325 325
         ]);
326 326
 
327 327
         $url = $discovery['userinfo_endpoint'].'?access_token='.$this->access_token;
@@ -336,13 +336,13 @@  discard block
 block discarded – undo
336 336
         if($code === 200) {
337 337
             $attributes = json_decode($result, true);
338 338
             $this->logger->debug('successfully requested user attributes from userinfo_endpoint', [
339
-               'category' => get_class($this),
339
+                'category' => get_class($this),
340 340
             ]);
341 341
 
342 342
             return $this->attributes = $attributes;
343 343
         } else {
344 344
             $this->logger->error('failed requesting user attributes from userinfo_endpoint, status code ['.$code.']', [
345
-               'category' => get_class($this),
345
+                'category' => get_class($this),
346 346
             ]);
347 347
 
348 348
             throw new Exception('failed requesting user attribute from userinfo_endpoint');
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
      * @param   Iterable $config
70 70
      * @return  void
71 71
      */
72
-    public function __construct(LoggerInterface $logger, ?Iterable $config=null)
72
+    public function __construct(LoggerInterface $logger, ?Iterable $config = null)
73 73
     {
74 74
         $this->logger = $logger;
75 75
         $this->setOptions($config);
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
             return $this;
89 89
         }
90 90
 
91
-        foreach($config as $option => $value) {
92
-            switch($option) {
91
+        foreach ($config as $option => $value) {
92
+            switch ($option) {
93 93
                 case 'provider_url':
94 94
                 case 'token_validation_url':
95 95
                 case 'identity_attribute':
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
             $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
172 172
             curl_close($ch);
173 173
 
174
-            if($code === 200) {
174
+            if ($code === 200) {
175 175
                 $discovery = json_decode($result, true);
176 176
                 $this->logger->debug('received openid-connect discovery document from ['.$url.']', [
177 177
                     'category' => get_class($this),
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
      */
203 203
     protected function verifyToken(string $token): bool
204 204
     {
205
-        if($this->token_validation_url) {
205
+        if ($this->token_validation_url) {
206 206
             $this->logger->debug('validate oauth2 token via rfc7662 token validation endpoint ['.$this->token_validation_url.']', [
207 207
                'category' => get_class($this),
208 208
             ]);
@@ -257,12 +257,12 @@  discard block
 block discarded – undo
257 257
             return false;
258 258
         }
259 259
 
260
-        if($response['active']) {
260
+        if ($response['active']) {
261 261
             $this->logger->debug('successfully verified oauth2 access token via authorization server', [
262 262
                'category' => get_class($this),
263 263
             ]);
264 264
 
265
-            if(!isset($response['username'])) {
265
+            if (!isset($response['username'])) {
266 266
                 throw new Exception('attribute \'username\' not found in oauth2 response');
267 267
             }
268 268
 
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
      * @param   array $response
283 283
      * @return  bool
284 284
      */
285
-    protected function verifyUserinfo(int $code, ?array $response): bool
285
+    protected function verifyUserinfo(int $code, ? array $response) : bool
286 286
     {
287 287
         if ($code === 200) {
288 288
             $attributes = $response;
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
                'category' => get_class($this),
291 291
             ]);
292 292
 
293
-            if(!isset($attributes[$this->identity_attribute])) {
293
+            if (!isset($attributes[$this->identity_attribute])) {
294 294
                 throw new Exception('identity attribute '.$this->identity_attribute.' not found in oauth2 response');
295 295
             }
296 296
 
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
      */
312 312
     public function getAttributes(): array
313 313
     {
314
-        if(count($this->attributes) !== 0) {
314
+        if (count($this->attributes) !== 0) {
315 315
             return $this->attributes;
316 316
         }
317 317
 
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
         curl_close($ch);
334 334
         $response = json_decode($result, true);
335 335
 
336
-        if($code === 200) {
336
+        if ($code === 200) {
337 337
             $attributes = json_decode($result, true);
338 338
             $this->logger->debug('successfully requested user attributes from userinfo_endpoint', [
339 339
                'category' => get_class($this),
Please login to merge, or discard this patch.