Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/aws cognito logout #421

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,20 @@ $oidc->setPrivateKeyJwtGenerator(function(string $token_endpoint) {
})
```

## Example 11: Enable logout behavior for AWS Cognito

```php
// NOTE: assumes that $oidc is an instance of OpenIDConnectClient()

// enable logout behavior for AWS Cognito before call signOut()
$oidc->setAwsCognitoFlow(true);

// call the signOut() function
// Be sure to get $idToken and $redirect from the logout request
$oidc->signOut($idToken, $redirect);

// Referente: https://docs.aws.amazon.com/cognito/latest/developerguide/logout-endpoint.html
```

## Development Environments ##
In some cases you may need to disable SSL security on your development systems.
Expand Down
15 changes: 15 additions & 0 deletions src/OpenIDConnectClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@ class OpenIDConnectClient
*/
private $token_endpoint_auth_methods_supported = ['client_secret_basic'];

/**
* @var bool Enable or disable logout parameters for AWS Cognito
*/
private $awsCognitoFlow = false;

/**
* @param string|null $provider_url optional
* @param string|null $client_id optional
Expand Down Expand Up @@ -439,6 +444,12 @@ public function signOut(string $idToken, $redirect) {
if($redirect === null){
$signout_params = ['id_token_hint' => $idToken];
}
elseif($this->awsCognitoFlow){
$signout_params = [
'id_token_hint' => $idToken,
'client_id' => $this->clientID,
'logout_uri' => $redirect];
}
else {
$signout_params = [
'id_token_hint' => $idToken,
Expand Down Expand Up @@ -2022,6 +2033,10 @@ public function setCodeChallengeMethod(string $codeChallengeMethod) {
$this->codeChallengeMethod = $codeChallengeMethod;
}

public function setAwsCognitoFlow(bool $awsCognitoFlow) {
$this->awsCognitoFlow = $awsCognitoFlow;
}

/**
* @throws OpenIDConnectClientException
*/
Expand Down