@@ -106,7 +106,7 @@ |
||
106 | 106 | * Response constructor. |
107 | 107 | * @param string $accessToken |
108 | 108 | * @param string $tokenType |
109 | - * @param int|null $expiresIn |
|
109 | + * @param integer $expiresIn |
|
110 | 110 | * @param null|string $refreshToken |
111 | 111 | * @param null|string $scope |
112 | 112 | */ |
@@ -10,7 +10,6 @@ |
||
10 | 10 | |
11 | 11 | |
12 | 12 | use GuzzleHttp\Psr7\Response; |
13 | -use Psr\Http\Message\UriInterface; |
|
14 | 13 | |
15 | 14 | /** |
16 | 15 | * Class AccessTokenResponse |
@@ -10,8 +10,6 @@ |
||
10 | 10 | |
11 | 11 | |
12 | 12 | use GuzzleHttp\Psr7\Response; |
13 | -use GuzzleHttp\Psr7\Uri; |
|
14 | -use Psr\Http\Message\UriInterface; |
|
15 | 13 | |
16 | 14 | class ErrorResponse extends Response |
17 | 15 | { |
@@ -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; |
@@ -12,7 +12,6 @@ |
||
12 | 12 | use OAuth2\Config; |
13 | 13 | use OAuth2\Exceptions\OAuthException; |
14 | 14 | use OAuth2\Repositories\ConfigurationRepository; |
15 | -use OAuth2\ResponseTypes\ResponseTypeInterface; |
|
16 | 15 | use OAuth2\Roles\Clients\RegisteredClient; |
17 | 16 | use OAuth2\Roles\ResourceOwnerInterface; |
18 | 17 | use OAuth2\Storages\AuthorizationCodeStorageInterface; |
@@ -40,7 +40,7 @@ |
||
40 | 40 | * @return array |
41 | 41 | */ |
42 | 42 | public function handle(ServerRequestInterface $request, ResourceOwnerInterface $resourceOwner, |
43 | - RegisteredClient $client, ?array $scope = null): array |
|
43 | + RegisteredClient $client, ?array $scope = null): array |
|
44 | 44 | { |
45 | 45 | // TODO: Implement handle() method. |
46 | 46 | } |
@@ -71,7 +71,7 @@ |
||
71 | 71 | ); |
72 | 72 | } |
73 | 73 | |
74 | - if(!$state && $this->configurationRepository->getConfig(Config::ENFORCE_STATE)) { |
|
74 | + if (!$state && $this->configurationRepository->getConfig(Config::ENFORCE_STATE)) { |
|
75 | 75 | throw new OAuthException('invalid_request', |
76 | 76 | 'Missing a required parameter : state', |
77 | 77 | 'http://openid.net/specs/openid-connect-core-1_0.html#AuthorizationEndpoint' |
@@ -68,7 +68,7 @@ |
||
68 | 68 | /** |
69 | 69 | * Server constructor. |
70 | 70 | * @param ResourceOwnerProviderInterface $resourceOwnerProvider |
71 | - * @param null|StorageRepository $storageRepository |
|
71 | + * @param StorageRepository $storageRepository |
|
72 | 72 | * @param null|ConfigurationRepository $configurationRepository |
73 | 73 | * @param ResponseTypeRepository $responseTypeRepository |
74 | 74 | * @param null|GrantTypeRepository $grantTypeRepository |
@@ -42,7 +42,7 @@ |
||
42 | 42 | * method available via the user-agent to accomplish this redirection is |
43 | 43 | * allowed and is considered to be an implementation detail |
44 | 44 | * |
45 | - * @param $uri |
|
45 | + * @param string $uri |
|
46 | 46 | * @return Response |
47 | 47 | */ |
48 | 48 | protected function redirectResponse($uri) |
@@ -74,18 +74,18 @@ discard block |
||
74 | 74 | protected function errorResponse(string $redirectUri, string $error, ?string $description = null, ?string $uri = null) |
75 | 75 | { |
76 | 76 | if ($this->containsNotAsciiChar($error)) { |
77 | - throw new \Exception('Malformed error type. Expect ascii string. Got : ' . $error); |
|
77 | + throw new \Exception('Malformed error type. Expect ascii string. Got : '.$error); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | if (!in_array($error, self::errors)) { |
81 | - throw new \Exception('Unexpected error type. Expect one of : ' . implode(', ', self::errors)); |
|
81 | + throw new \Exception('Unexpected error type. Expect one of : '.implode(', ', self::errors)); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | $data = ['error' => $error]; |
85 | 85 | |
86 | 86 | if ($description) { |
87 | 87 | if ($this->containsNotAsciiChar($description)) { |
88 | - throw new \Exception('Malformed error description. Expect ascii string. Got : ' . $description); |
|
88 | + throw new \Exception('Malformed error description. Expect ascii string. Got : '.$description); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | $data['error_description'] = $description; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | if ($uri) { |
95 | 95 | if ($this->containsNotAsciiChar($uri)) { |
96 | - throw new \Exception('Malformed error uri. Expect ascii string. Got : ' . $uri); |
|
96 | + throw new \Exception('Malformed error uri. Expect ascii string. Got : '.$uri); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | $data['error_uri'] = $uri; |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | $redirectUri = new Uri($redirectUri); |
103 | 103 | $query = http_build_query($data); |
104 | 104 | if ($redirectUri->getQuery()) { |
105 | - $query .= '&' . $redirectUri->getQuery(); |
|
105 | + $query .= '&'.$redirectUri->getQuery(); |
|
106 | 106 | } |
107 | - $redirectUri = $redirectUri->getScheme() . ':' . $redirectUri->getHierPart() . '?' . $query; |
|
107 | + $redirectUri = $redirectUri->getScheme().':'.$redirectUri->getHierPart().'?'.$query; |
|
108 | 108 | |
109 | 109 | return $this->redirectResponse($redirectUri); |
110 | 110 | } |
@@ -274,7 +274,7 @@ |
||
274 | 274 | * @param RegisteredClient $client |
275 | 275 | * @param null|string $redirectUri |
276 | 276 | * @param bool $isImplicitGrant |
277 | - * @return Uri|null|string |
|
277 | + * @return \Psr\Http\Message\UriInterface |
|
278 | 278 | * @throws \Exception |
279 | 279 | */ |
280 | 280 | private function checkClientRedirectUri(RegisteredClient $client, ?string $redirectUri, $isImplicitGrant = false) |
@@ -10,20 +10,16 @@ |
||
10 | 10 | |
11 | 11 | use GuzzleHttp\Psr7\Response; |
12 | 12 | use GuzzleHttp\Psr7\Uri; |
13 | -use OAuth2\Credential\AuthorizationCode; |
|
14 | 13 | use OAuth2\Endpoint\Config; |
15 | 14 | use OAuth2\Endpoint\Endpoint; |
16 | 15 | use OAuth2\Endpoint\Server\Messages\Authorization\AuthorizationRequest as AuthorizationRequest; |
17 | -use OAuth2\Endpoint\Server\Messages\Authorization\AuthorizationResponse as AuthorizationResponse; |
|
18 | 16 | use OAuth2\Endpoint\Server\Messages\Authorization\ErrorResponse; |
19 | 17 | use OAuth2\Exception\MissingResourceOwnerDecision; |
20 | 18 | use OAuth2\Exception\ResourceOwnerNotAuthenticatedException; |
21 | 19 | use OAuth2\ResponseType\ResponseTypeInterface; |
22 | -use OAuth2\Storage\ClientStorage; |
|
23 | 20 | use OAuth2\Role\Client\RegisteredClient; |
24 | 21 | use OAuth2\Role\Client\Type\ClientPassword; |
25 | 22 | use OAuth2\Role\Client\Type\PublicClient; |
26 | -use OAuth2\Role\Client\WebApplication; |
|
27 | 23 | use OAuth2\Role\ResourceOwner; |
28 | 24 | |
29 | 25 |
@@ -175,12 +175,12 @@ discard block |
||
175 | 175 | $responseTypes = []; |
176 | 176 | foreach (explode(' ', $request->getResponseType()) as $responseTypeRequested) { |
177 | 177 | $responseType = $this->server->getResponseType($responseTypeRequested); |
178 | - if(!$responseType) { |
|
178 | + if (!$responseType) { |
|
179 | 179 | return new ErrorResponse($redirectUri, 'unsupported_response_type', 'Invalid response_type parameter', |
180 | 180 | 'https://tools.ietf.org/html/rfc6749#section-3.1.1'); |
181 | 181 | } |
182 | 182 | |
183 | - if($responseType->isImplicit()) { |
|
183 | + if ($responseType->isImplicit()) { |
|
184 | 184 | $isImplicitResponseType = true; |
185 | 185 | } |
186 | 186 | |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | $params['state'] = $request->getState(); |
237 | 237 | } |
238 | 238 | |
239 | - if($isImplicitResponseType) { |
|
239 | + if ($isImplicitResponseType) { |
|
240 | 240 | $redirectUri = $redirectUri->withFragment(http_build_query($params)); |
241 | 241 | } |
242 | 242 | else { |
@@ -238,8 +238,7 @@ |
||
238 | 238 | |
239 | 239 | if($isImplicitResponseType) { |
240 | 240 | $redirectUri = $redirectUri->withFragment(http_build_query($params)); |
241 | - } |
|
242 | - else { |
|
241 | + } else { |
|
243 | 242 | foreach ($params as $key => $value) { |
244 | 243 | $redirectUri = Uri::withQueryValue($redirectUri, $key, $value); |
245 | 244 | } |
@@ -115,7 +115,7 @@ |
||
115 | 115 | * @param UriInterface $redirectUri |
116 | 116 | * @param string $accessToken |
117 | 117 | * @param string $tokenType |
118 | - * @param int|null $expiresIn |
|
118 | + * @param integer $expiresIn |
|
119 | 119 | * @param null|string $refreshToken |
120 | 120 | * @param null|string $scope |
121 | 121 | */ |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | |
142 | 142 | /** |
143 | 143 | * @param string $name |
144 | - * @return mixed |
|
144 | + * @return boolean |
|
145 | 145 | * @throws \Exception |
146 | 146 | */ |
147 | 147 | public function getConfig(string $name) |
@@ -161,6 +161,9 @@ discard block |
||
161 | 161 | return $this->grantTypes[$uri] ?? null; |
162 | 162 | } |
163 | 163 | |
164 | + /** |
|
165 | + * @return \OAuth2\Storages\AuthorizationCodeStorageInterface |
|
166 | + */ |
|
164 | 167 | public function getStorage(string $name) |
165 | 168 | { |
166 | 169 | return $this->storages[$name]; |
@@ -18,7 +18,6 @@ |
||
18 | 18 | use OAuth2\Storage\AuthorizationCodeStorage; |
19 | 19 | use OAuth2\Storage\ClientStorage; |
20 | 20 | use OAuth2\Role\Client\RegisteredClient; |
21 | -use OAuth2\Role\Client\Type\ClientPassword; |
|
22 | 21 | use Psr\Http\Message\ServerRequestInterface; |
23 | 22 | |
24 | 23 | class Server |
@@ -90,15 +90,15 @@ discard block |
||
90 | 90 | { |
91 | 91 | foreach (self::STORAGES as $name => $class) { |
92 | 92 | if (!isset($storages[$name])) { |
93 | - throw new \Exception('Missing storage "' . $name . '"'); |
|
93 | + throw new \Exception('Missing storage "'.$name.'"'); |
|
94 | 94 | } |
95 | 95 | if (!is_a($storages[$name], $class)) { |
96 | - throw new \Exception('Storage "' . $name . '" must implement interface "' . $class . '"'); |
|
96 | + throw new \Exception('Storage "'.$name.'" must implement interface "'.$class.'"'); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | 100 | if (array_diff(self::MINIMAL_CONFIG, array_keys($config))) { |
101 | - throw new \Exception('Missing minimal configuration. Required : ' . implode(', ', self::MINIMAL_CONFIG)); |
|
101 | + throw new \Exception('Missing minimal configuration. Required : '.implode(', ', self::MINIMAL_CONFIG)); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | $this->config = array_merge(self::DEFAULT_CONFIG, $config); |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function getConfig(string $name) |
148 | 148 | { |
149 | - if(!isset($this->config[$name])) { |
|
149 | + if (!isset($this->config[$name])) { |
|
150 | 150 | throw new \Exception('Config with name "'.$name.'" not found'); |
151 | 151 | } |
152 | 152 | return $this->config[$name]; |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | public function authenticate(ServerRequestInterface $request) |
393 | 393 | { |
394 | 394 | $this->client = $this->guard->authenticate($request); |
395 | - return (bool)$this->client; |
|
395 | + return (bool) $this->client; |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | /** |
@@ -11,19 +11,11 @@ |
||
11 | 11 | use GuzzleHttp\Psr7\Uri; |
12 | 12 | use OAuth2\Credential\AccessToken; |
13 | 13 | use OAuth2\Credential\RefreshToken; |
14 | -use OAuth2\Credential\TokenType\BearerToken; |
|
15 | -use OAuth2\Endpoint\Config; |
|
16 | 14 | use OAuth2\Endpoint\Server\Messages\AccessToken\AccessTokenRequest; |
17 | 15 | use OAuth2\Endpoint\Server\Messages\AccessToken\AccessTokenResponse; |
18 | -use OAuth2\Endpoint\Server\Messages\Authorization\AuthorizationRequest; |
|
19 | 16 | use OAuth2\Endpoint\Server\Messages\AccessToken\ErrorResponse; |
20 | -use OAuth2\GrantType\AuthorizationCode; |
|
21 | 17 | use OAuth2\GrantType\InvalidGrantType; |
22 | -use OAuth2\Storage\ClientStorage; |
|
23 | 18 | use OAuth2\Role\Client; |
24 | -use OAuth2\Role\Client\RegisteredClient; |
|
25 | -use OAuth2\Role\Client\Type\ClientPassword; |
|
26 | -use Psr\Http\Message\ServerRequestInterface; |
|
27 | 19 | |
28 | 20 | |
29 | 21 | /** |
@@ -167,7 +167,7 @@ |
||
167 | 167 | try { |
168 | 168 | $redirectUri = $grantType->grant($request, $client); |
169 | 169 | } |
170 | - catch(InvalidGrantType $e) { |
|
170 | + catch (InvalidGrantType $e) { |
|
171 | 171 | return new ErrorResponse('invalid_grant', $e->getErrorDescription(), $e->getErrorUri()); |
172 | 172 | } |
173 | 173 |
@@ -166,8 +166,7 @@ |
||
166 | 166 | |
167 | 167 | try { |
168 | 168 | $redirectUri = $grantType->grant($request, $client); |
169 | - } |
|
170 | - catch(InvalidGrantType $e) { |
|
169 | + } catch(InvalidGrantType $e) { |
|
171 | 170 | return new ErrorResponse('invalid_grant', $e->getErrorDescription(), $e->getErrorUri()); |
172 | 171 | } |
173 | 172 |