Completed
Push — master ( 5cc957...6e52f0 )
by Alexandre
03:24
created
src/OAuth2/EndpointMessages/Authorization/ErrorResponse.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -37,18 +37,18 @@  discard block
 block discarded – undo
37 37
                                 ?string $errorUri = null, ?string $state = null)
38 38
     {
39 39
         if ($this->containsNotAsciiChar($error)) {
40
-            throw new \Exception('Malformed error type. Expect ascii string. Got : ' . $error);
40
+            throw new \Exception('Malformed error type. Expect ascii string. Got : '.$error);
41 41
         }
42 42
 
43 43
         if (!in_array($error, self::errors)) {
44
-            throw new \Exception('Unexpected error type. Expect one of : ' . implode(', ', self::errors));
44
+            throw new \Exception('Unexpected error type. Expect one of : '.implode(', ', self::errors));
45 45
         }
46 46
 
47 47
         $redirectUri = Uri::withQueryValue($redirectUri, 'error', $error);
48 48
 
49 49
         if ($errorDescription) {
50 50
             if ($this->containsNotAsciiChar($errorDescription)) {
51
-                throw new \Exception('Malformed error description. Expect ascii string. Got : ' . $errorDescription);
51
+                throw new \Exception('Malformed error description. Expect ascii string. Got : '.$errorDescription);
52 52
             }
53 53
 
54 54
             $redirectUri = Uri::withQueryValue($redirectUri, 'error_description', $errorDescription);
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
 
57 57
         if ($errorUri) {
58 58
             if ($this->containsNotAsciiChar($errorUri)) {
59
-                throw new \Exception('Malformed error uri. Expect ascii string. Got : ' . $errorUri);
59
+                throw new \Exception('Malformed error uri. Expect ascii string. Got : '.$errorUri);
60 60
             }
61 61
 
62 62
             $redirectUri = Uri::withQueryValue($redirectUri, 'error_uri', $errorUri);
63 63
         }
64 64
 
65
-        if($state) {
65
+        if ($state) {
66 66
             $redirectUri = Uri::withQueryValue($redirectUri, 'state', $state);
67 67
         }
68 68
 
Please login to merge, or discard this patch.
src/OAuth2/Endpoints/AuthorizationEndpoint.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -221,7 +221,7 @@
 block discarded – undo
221 221
             if (!$scopePolicyManager->checkScope($client, $scope)) {
222 222
                 $supportedScopes = implode(', ', $scopePolicyManager->getSupportedScopes($client));
223 223
                 throw new OAuthException('invalid_scope',
224
-                    'Some of requested scopes are not supported. Scope supported : ' . $supportedScopes,
224
+                    'Some of requested scopes are not supported. Scope supported : '.$supportedScopes,
225 225
                     'https://tools.ietf.org/html/rfc6749#section-4.1');
226 226
             }
227 227
 
Please login to merge, or discard this patch.
src/OAuth2/Endpoints/TokenEndpoint.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         $grantType = $this->server->getGrantTypeRepository()->getGrantType($grantTypeName);
37 37
         if (!$grantType) {
38 38
             return new ErrorResponse('unsupported_grant_type',
39
-                'Unsupported grant type : ' . $grantTypeName,
39
+                'Unsupported grant type : '.$grantTypeName,
40 40
                 'https://tools.ietf.org/html/rfc6749#section-5.2');
41 41
         }
42 42
 
@@ -54,18 +54,18 @@  discard block
 block discarded – undo
54 54
         } catch (OAuthException $e) {
55 55
             if ($e->getError() == 'invalid_client' && $request->hasHeader('Authorization')) {
56 56
                 return new ErrorResponse($e->getError(),
57
-                    'Client authentication failed : ' . $e->getMessage(),
57
+                    'Client authentication failed : '.$e->getMessage(),
58 58
                     $e->getErrorUri(), 401, [
59 59
                         'WWW-Authenticate' => 'Basic'
60 60
                     ]);
61 61
             } else {
62 62
                 return new ErrorResponse($e->getError(),
63
-                    'Client authentication failed : ' . $e->getMessage(),
63
+                    'Client authentication failed : '.$e->getMessage(),
64 64
                     $e->getErrorUri(), 401);
65 65
             }
66 66
         }
67 67
 
68
-        if(!$client) {
68
+        if (!$client) {
69 69
             if (!isset($request->getParsedBody()['client_id'])) {
70 70
                 return new ErrorResponse('invalid_request',
71 71
                     'Client authentication not included, missing a parameter : client_id : ',
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 
82 82
             if ($client->hasCredentials()) {
83 83
                 return new ErrorResponse('invalid_client',
84
-                    'Client authentication failed : ' . $guard->getError(),
84
+                    'Client authentication failed : '.$guard->getError(),
85 85
                     'https://tools.ietf.org/html/rfc6749#section-5.2', 401, [
86 86
                         'WWW-Authenticate' => 'Basic'
87 87
                     ]);
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 
91 91
         if (is_array($client->getSupportedGrantTypes()) && !in_array($grantType->getUri(), $client->getSupportedGrantTypes())) {
92 92
             return new ErrorResponse('unauthorized_client',
93
-                'Unauthorized grant type : ' . $grantType->getUri(),
93
+                'Unauthorized grant type : '.$grantType->getUri(),
94 94
                 'https://tools.ietf.org/html/rfc6749#section-5.2');
95 95
         }
96 96
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -96,8 +96,7 @@
 block discarded – undo
96 96
 
97 97
         try {
98 98
             return $grantType->grant($request, $client);
99
-        }
100
-        catch (OAuthException $e) {
99
+        } catch (OAuthException $e) {
101 100
             return new ErrorResponse($e->getError(),
102 101
                 $e->getErrorDescription(),
103 102
                 $e->getErrorUri());
Please login to merge, or discard this patch.
src/OAuth2/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/OAuth2/Repositories/ConfigurationRepository.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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];
Please login to merge, or discard this patch.
src/OAuth2/Repositories/GrantTypeRepository.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@
 block discarded – undo
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,
Please login to merge, or discard this patch.
src/OAuth2/ScopePolicy/Policies/ScopePolicyInterface.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,5 +14,5 @@
 block discarded – undo
14 14
 interface ScopePolicyInterface
15 15
 {
16 16
 //    function check(array $scope, ClientInterface $client): bool ;
17
-    function getDefaultScopes(ClientInterface $client) : ?array ;
17
+    function getDefaultScopes(ClientInterface $client) : ?array;
18 18
 }
19 19
\ No newline at end of file
Please login to merge, or discard this patch.
src/OAuth2/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/OAuth2/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.