diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2024-09-04 09:48:56 +0000 |
|---|---|---|
| committer | Murtaza Sultani <sultani@data-quest.de> | 2024-09-17 16:42:23 +0200 |
| commit | c96e55ec6245afdbbfc3a7a708f450333053d22b (patch) | |
| tree | bfcba7b501cba9d3d692b17bd538613bc1cb9a87 | |
| parent | 6e3ca2f07b3c7770500c6884ce6d879c3ac0c57f (diff) | |
add option to perform an oauth2 specific logout, re #4482, re #3624
Merge request studip/studip!3366
| -rw-r--r-- | config/config_defaults.inc.php | 1 | ||||
| -rw-r--r-- | lib/classes/auth_plugins/StudipAuthOAuth2.php | 13 |
2 files changed, 14 insertions, 0 deletions
diff --git a/config/config_defaults.inc.php b/config/config_defaults.inc.php index d0f7d69..2f83fef 100644 --- a/config/config_defaults.inc.php +++ b/config/config_defaults.inc.php @@ -307,6 +307,7 @@ $STUDIP_AUTH_CONFIG_OAUTH2 = [ 'client_id' => '', 'client_secret' => '', 'redirect_uri' => '', + 'logout_url' => '', 'url_authorize' => '', 'url_access_token' => '', diff --git a/lib/classes/auth_plugins/StudipAuthOAuth2.php b/lib/classes/auth_plugins/StudipAuthOAuth2.php index aa90776..98ee90b 100644 --- a/lib/classes/auth_plugins/StudipAuthOAuth2.php +++ b/lib/classes/auth_plugins/StudipAuthOAuth2.php @@ -18,6 +18,8 @@ final class StudipAuthOAuth2 extends StudipAuthSSO protected string $url_access_token; protected string $url_resource_owner_details; + protected ?string $logout_url = null; + private GenericProvider $oauth2_provider; private ?array $user_data = null; @@ -110,4 +112,15 @@ final class StudipAuthOAuth2 extends StudipAuthSSO { return $this->user_data_mapping['map_args']['auth_user_md5.username'] ?? 'nickname'; } + + /** + * Perform logout if a logout url has been configured + */ + public function logout(): void + { + if (!empty($this->logout_url)) { + header('Location: ' . $this->logout_url); + exit(); + } + } } |
