Skip to content

Commit

Permalink
Add setting oidc_refresh_tokens_enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
akhil1508 committed Jan 6, 2023
1 parent 299d3e1 commit 4858815
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ $CONFIG = array (
// - 'plain'
// The default value is empty, which won't apply the PKCE flow.
'oidc_login_code_challenge_method' => '',

// If OIDC server has refresh tokens enabled and
// you want to manage session at OIDC server by storing
// and refreshing tokens. Defaults to false.
'oidc_refresh_tokens_enabled' => false,

);
```
### Usage with [Keycloak](https://www.keycloak.org/)
Expand Down
3 changes: 2 additions & 1 deletion lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ public function boot(IBootContext $context): void
});
}

if (!$this->tokenService->refreshTokens()) {
$refreshTokensEnabled = $this->config->getSystemValue('oidc_refresh_tokens_enabled', false);
if ($refreshTokensEnabled && !$this->tokenService->refreshTokens()) {
$userSession->logout();
}

Expand Down
5 changes: 4 additions & 1 deletion lib/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,11 @@ public function oidc()
$oidc->authenticate();

$tokenResponse = $oidc->getTokenResponse();
$this->tokenService->storeTokens($tokenResponse);
$refreshTokensEnabled = $this->config->getSystemValue('oidc_refresh_tokens_enabled', false);

if ($refreshTokensEnabled) {
$this->tokenService->storeTokens($tokenResponse);
}
$user = null;
if ($this->config->getSystemValue('oidc_login_use_id_token', false)) {
// Get user information from ID Token
Expand Down

0 comments on commit 4858815

Please sign in to comment.