Skip to content

Commit 11edc74

Browse files
committed
move call to createClient() to be first call in methods to populate openid config array
1 parent 7653063 commit 11edc74

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/Cidaas.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Cidaas {
2626
private static string $handleResetPasswordUri = '/users-srv/resetpassword/validatecode';
2727
private static string $resetPasswordUri = '/users-srv/resetpassword/accept';
2828

29-
private $openid_config;
29+
private array $openid_config;
3030
private string $baseUrl = "";
3131
private string $clientId = "";
3232
private string $clientSecret = "";
@@ -309,9 +309,8 @@ public function getAccessToken(string $grantType, string $code = '', string $ref
309309
throw new \InvalidArgumentException('invalid grant type');
310310
}
311311

312-
$url = $this->openid_config["token_endpoint"];
313-
314312
$client = $this->createClient();
313+
$url = $this->openid_config["token_endpoint"];
315314
$responsePromise = $client->requestAsync('POST', $url, ['form_params' => $params]);
316315
return $responsePromise->then(function (ResponseInterface $response) {
317316
$body = $response->getBody();
@@ -326,12 +325,12 @@ public function getAccessToken(string $grantType, string $code = '', string $ref
326325
* @return PromiseInterface promise with user profile or error
327326
*/
328327
public function getUserProfile(string $accessToken, string $sub = ""): PromiseInterface {
328+
$client = $this->createClient();
329329
$url = $this->openid_config["userinfo_endpoint"];
330330
if (!empty($sub)) {
331331
$url .= "/" . $sub;
332332
}
333333

334-
$client = $this->createClient();
335334
$responsePromise = $client->requestAsync('POST', $url, [
336335
"headers" => [
337336
"Authorization" => "Bearer " . $accessToken,
@@ -508,13 +507,13 @@ public function validateAccessToken(string $accessTokenToValidate, $accessTokenF
508507
* @return PromiseInterface promise with success (redirect) or error message
509508
*/
510509
public function logout(string $accessToken, string $postLogoutUri = ""): PromiseInterface {
510+
$client = $this->createClient();
511511
$url = $this->openid_config["end_session_endpoint"] . "?access_token_hint=" . $accessToken;
512512

513513
if (!empty($postLogoutUri)) {
514514
$url .= "&post_logout_redirect_uri=" . urlencode($postLogoutUri);
515515
}
516516

517-
$client = $this->createClient();
518517
return $client->requestAsync('POST', $url, ['allow_redirects' => false]);
519518
}
520519

0 commit comments

Comments
 (0)