1 | <?php |
||
14 | class Keycloak extends AbstractProvider |
||
15 | { |
||
16 | use BearerAuthorizationTrait; |
||
17 | |||
18 | /** |
||
19 | * Keycloak URL, eg. http://localhost:8080/auth. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | public $authServerUrl = null; |
||
24 | |||
25 | /** |
||
26 | * Realm name, eg. demo. |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | public $realm = null; |
||
31 | |||
32 | /** |
||
33 | * Encryption algorithm. |
||
34 | * |
||
35 | * You must specify supported algorithms for your application. See |
||
36 | * https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40 |
||
37 | * for a list of spec-compliant algorithms. |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | public $encryptionAlgorithm = null; |
||
42 | |||
43 | /** |
||
44 | * Encryption key. |
||
45 | * |
||
46 | * @var string |
||
47 | */ |
||
48 | public $encryptionKey = null; |
||
49 | |||
50 | /** |
||
51 | * Constructs an OAuth 2.0 service provider. |
||
52 | * |
||
53 | * @param array $options An array of options to set on this provider. |
||
54 | * Options include `clientId`, `clientSecret`, `redirectUri`, and `state`. |
||
55 | * Individual providers may introduce more options, as needed. |
||
56 | * @param array $collaborators An array of collaborators that may be used to |
||
57 | * override this provider's default behavior. Collaborators include |
||
58 | * `grantFactory`, `requestFactory`, `httpClient`, and `randomFactory`. |
||
59 | * Individual providers may introduce more collaborators, as needed. |
||
60 | */ |
||
61 | public function __construct(array $options = [], array $collaborators = []) |
||
69 | |||
70 | /** |
||
71 | * Attempts to decrypt the given response. |
||
72 | * |
||
73 | * @param string|array|null $response |
||
74 | * |
||
|
|||
75 | * @return string|array|null |
||
76 | */ |
||
77 | |||
78 | public function verifyUser(array $provider){ |
||
153 | |||
154 | /** |
||
155 | * Get authorization url to begin OAuth flow |
||
156 | * |
||
157 | * @return string |
||
158 | */ |
||
159 | public function getBaseAuthorizationUrl() |
||
163 | |||
164 | /** |
||
165 | * Get access token url to retrieve token |
||
166 | * |
||
167 | * @param array $params |
||
168 | * |
||
169 | * @return string |
||
170 | */ |
||
171 | public function getBaseAccessTokenUrl(array $params) |
||
175 | |||
176 | /** |
||
177 | * Get provider url to fetch user details |
||
178 | * |
||
179 | * @param AccessToken $token |
||
180 | * |
||
181 | * @return string |
||
182 | */ |
||
183 | public function getResourceOwnerDetailsUrl(AccessToken $token) |
||
187 | |||
188 | /** |
||
189 | * Builds the logout URL. |
||
190 | * |
||
191 | * @param array $options |
||
192 | * @return string Authorization URL |
||
193 | */ |
||
194 | public function getLogoutUrl(array $options = []) |
||
201 | |||
202 | /** |
||
203 | * Get logout url to logout of session token |
||
204 | * |
||
205 | * @return string |
||
206 | */ |
||
207 | private function getBaseLogoutUrl() |
||
211 | |||
212 | /** |
||
213 | * Creates base url from provider configuration. |
||
214 | * |
||
215 | * @return string |
||
216 | */ |
||
217 | protected function getBaseUrlWithRealm() |
||
221 | |||
222 | /** |
||
223 | * Get the default scopes used by this provider. |
||
224 | * |
||
225 | * This should not be a complete list of all scopes, but the minimum |
||
226 | * required for the provider user interface! |
||
227 | * |
||
228 | * @return string[] |
||
229 | */ |
||
230 | protected function getDefaultScopes() |
||
234 | |||
235 | /** |
||
236 | * Check a provider response for errors. |
||
237 | * |
||
238 | * @throws IdentityProviderException |
||
239 | * @param ResponseInterface $response |
||
240 | * @param string $data Parsed response data |
||
241 | * @return void |
||
242 | */ |
||
243 | protected function checkResponse(ResponseInterface $response, $data) |
||
250 | |||
251 | /** |
||
252 | * Generate a user object from a successful user details request. |
||
253 | * |
||
254 | * @param array $response |
||
255 | * @param AccessToken $token |
||
256 | * @return KeycloakResourceOwner |
||
257 | */ |
||
258 | protected function createResourceOwner(array $response, AccessToken $token) |
||
262 | |||
263 | /** |
||
264 | * Requests and returns the resource owner of given access token. |
||
265 | * |
||
266 | * @param AccessToken $token |
||
267 | * @return KeycloakResourceOwner |
||
268 | */ |
||
269 | public function getResourceOwner(AccessToken $token) |
||
277 | |||
278 | /** |
||
279 | * Updates expected encryption algorithm of Keycloak instance. |
||
280 | * |
||
281 | * @param string $encryptionAlgorithm |
||
282 | * |
||
283 | * @return Keycloak |
||
284 | */ |
||
285 | public function setEncryptionAlgorithm($encryptionAlgorithm) |
||
291 | |||
292 | /** |
||
293 | * Updates expected encryption key of Keycloak instance. |
||
294 | * |
||
295 | * @param string $encryptionKey |
||
296 | * |
||
297 | * @return Keycloak |
||
298 | */ |
||
299 | public function setEncryptionKey($encryptionKey) |
||
305 | |||
306 | /** |
||
307 | * Updates expected encryption key of Keycloak instance to content of given |
||
308 | * file path. |
||
309 | * |
||
310 | * @param string $encryptionKeyPath |
||
311 | * |
||
312 | * @return Keycloak |
||
313 | */ |
||
314 | public function setEncryptionKeyPath($encryptionKeyPath) |
||
324 | |||
325 | /** |
||
326 | * Checks if provider is configured to use encryption. |
||
327 | * |
||
328 | * @return bool |
||
329 | */ |
||
330 | public function usesEncryption() |
||
334 | } |
||
335 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.