@@ -37,18 +37,18 @@ discard block |
||
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 |
||
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 |
@@ -94,10 +94,10 @@ |
||
94 | 94 | */ |
95 | 95 | static public function createFromServerRequest(ServerRequestInterface $request) |
96 | 96 | { |
97 | - if(!isset($request->getParsedBody()['grant_type'])) { |
|
97 | + if (!isset($request->getParsedBody()['grant_type'])) { |
|
98 | 98 | throw new \Exception('Missing a required parameter : grant_type'); |
99 | 99 | } |
100 | - if(!isset($request->getParsedBody()['code'])) { |
|
100 | + if (!isset($request->getParsedBody()['code'])) { |
|
101 | 101 | throw new \Exception('Missing a required parameter : code'); |
102 | 102 | } |
103 | 103 |
@@ -37,25 +37,25 @@ |
||
37 | 37 | public function __construct(string $error, ?string $errorDescription = null, ?string $errorUri = null, int $status = 400, array $headers = []) |
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 | $data = ['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 | $data['error_description'] = $errorDescription; |
54 | 54 | } |
55 | 55 | |
56 | 56 | if ($errorUri) { |
57 | 57 | if ($this->containsNotAsciiChar($errorUri)) { |
58 | - throw new \Exception('Malformed error uri. Expect ascii string. Got : ' . $errorUri); |
|
58 | + throw new \Exception('Malformed error uri. Expect ascii string. Got : '.$errorUri); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | $data['error_uri'] = $errorUri; |
@@ -14,5 +14,5 @@ |
||
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 |
@@ -36,7 +36,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -221,7 +221,7 @@ |
||
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 |
@@ -74,25 +74,25 @@ discard block |
||
74 | 74 | ]; |
75 | 75 | |
76 | 76 | // todo, include if auth_time is marked as an essential claim by the client otherwise it is optional (conf ?) |
77 | - if(isset($data['max_age']) && $data['max_age']) { |
|
77 | + if (isset($data['max_age']) && $data['max_age']) { |
|
78 | 78 | $claims['auth_time'] = $resourceOwner->getTimeWhenAuthenticationOccured(); |
79 | 79 | } |
80 | 80 | |
81 | - if(isset($data['nonce']) && !is_null($data['nonce'])) { |
|
81 | + if (isset($data['nonce']) && !is_null($data['nonce'])) { |
|
82 | 82 | $claims['nonce'] = $data['nonce']; |
83 | 83 | } |
84 | 84 | |
85 | - if(empty($extendedResponseTypes)) { |
|
85 | + if (empty($extendedResponseTypes)) { |
|
86 | 86 | $standardClaims = $this->userInfoClaimsStorage->getClaims($resourceOwner); |
87 | 87 | |
88 | 88 | foreach ($this->userInfoClaimsStorage->getClaimsByScope($scope) as $claimRequested) { |
89 | - if(isset($standardClaims[$claimRequested]) && $standardClaims[$claimRequested]) { |
|
89 | + if (isset($standardClaims[$claimRequested]) && $standardClaims[$claimRequested]) { |
|
90 | 90 | $claims[$claimRequested] = $standardClaims[$claimRequested]; |
91 | 91 | } |
92 | 92 | } |
93 | 93 | } |
94 | 94 | |
95 | - if(isset($extendedResponseTypes['code'])) { |
|
95 | + if (isset($extendedResponseTypes['code'])) { |
|
96 | 96 | //c_hash |
97 | 97 | /** |
98 | 98 | * @var \OAuth2OLD\ResponseTypes\ResponseTypeInterface $responseType |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | $claims['c_hash'] = 'todo'; //todo |
104 | 104 | } |
105 | 105 | |
106 | - if(isset($extendedResponseTypes['token'])) { |
|
106 | + if (isset($extendedResponseTypes['token'])) { |
|
107 | 107 | //at_hash |
108 | 108 | /** |
109 | 109 | * @var \OAuth2OLD\ResponseTypes\ResponseTypeInterface $responseType |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | /** |
39 | 39 | * @var RegisteredClient $client |
40 | 40 | */ |
41 | - if($res = $this->verify($request, $result)) { |
|
41 | + if ($res = $this->verify($request, $result)) { |
|
42 | 42 | return $res; |
43 | 43 | } |
44 | 44 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | $result = []; |
57 | 57 | |
58 | 58 | try { |
59 | - if(!$resourceOwner->isConsentGivenForClient($client)) { |
|
59 | + if (!$resourceOwner->isConsentGivenForClient($client)) { |
|
60 | 60 | throw new OAuthException('access_denied', |
61 | 61 | 'The resource owner server denied the request', |
62 | 62 | 'https://tools.ietf.org/html/rfc6749#section-4.1.1'); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @var ResponseTypeInterface $responseType |
69 | 69 | */ |
70 | 70 | foreach ($responseTypes as $responseType) { |
71 | - if($responseType->getExtendedResponseTypes()) { |
|
71 | + if ($responseType->getExtendedResponseTypes()) { |
|
72 | 72 | $extendedResponseTypes = array_merge($extendedResponseTypes, $responseType->getExtendedResponseTypes()); |
73 | 73 | } |
74 | 74 | $responseTypeNames[] = $responseType->getResponseType(); |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @var ResponseTypeInterface $responseType |
79 | 79 | */ |
80 | 80 | foreach ($responseTypes as $responseType) { |
81 | - if(!in_array($responseType->getResponseType(), $extendedResponseTypes)) { |
|
81 | + if (!in_array($responseType->getResponseType(), $extendedResponseTypes)) { |
|
82 | 82 | $extendedResponseTypes = null; |
83 | 83 | if ($responseType->getExtendedResponseTypes()) { |
84 | 84 | $extendedResponseTypeNames = array_intersect($responseType->getExtendedResponseTypes(), array_keys($responseTypes)); |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | $data['state'] ?? null); |
99 | 99 | } |
100 | 100 | |
101 | - if(isset($data['state'])) { |
|
101 | + if (isset($data['state'])) { |
|
102 | 102 | $result['state'] = $data['state']; |
103 | 103 | } |
104 | 104 | |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | if (!$scopePolicyManager->checkScope($client, $scope)) { |
259 | 259 | $supportedScopes = implode(', ', $scopePolicyManager->getSupportedScopes($client)); |
260 | 260 | throw new OAuthException('invalid_scope', |
261 | - 'Some of requested scopes are not supported. Scope supported : ' . $supportedScopes, |
|
261 | + 'Some of requested scopes are not supported. Scope supported : '.$supportedScopes, |
|
262 | 262 | 'https://tools.ietf.org/html/rfc6749#section-4.1'); |
263 | 263 | } |
264 | 264 | |
@@ -417,12 +417,12 @@ discard block |
||
417 | 417 | $responseType = $this->server->getResponseTypeRepository()->getResponseType($responseTypeName); |
418 | 418 | if (!$responseType) { |
419 | 419 | throw new OAuthException('invalid_request', |
420 | - 'Unknown response_type : ' . $responseTypeName); |
|
420 | + 'Unknown response_type : '.$responseTypeName); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | if (!$responseType->isMultiValuedResponseTypeSupported()) { |
424 | 424 | throw new OAuthException('invalid_request', |
425 | - 'Multi-valued response_type not supported with response_type : ' . $responseTypeName); |
|
425 | + 'Multi-valued response_type not supported with response_type : '.$responseTypeName); |
|
426 | 426 | } |
427 | 427 | |
428 | 428 | $responseTypes[$responseTypeName] = $responseType; |
@@ -46,7 +46,7 @@ |
||
46 | 46 | $certsRepository = $this->sqlOauth->getRepository(Cert::class); |
47 | 47 | |
48 | 48 | $actualCerts = $certsRepository->findBy([], ['createdAt' => 'DESC'], 2); |
49 | - if(!isset($actualCerts[0])) { |
|
49 | + if (!isset($actualCerts[0])) { |
|
50 | 50 | list('privKey' => $privKey, 'pubKey' => $pubKey, 'rsa' => $rsa) = $this->generateRSAKeys(); |
51 | 51 | |
52 | 52 | $oldCert = new Cert(); |