From 9cda621d75b8681b9c0a015a766f05aa5d29d1d0 Mon Sep 17 00:00:00 2001 From: Vuong <3781991+kinekt4@users.noreply.github.com> Date: Tue, 14 May 2024 08:57:35 +1000 Subject: [PATCH] #1138 Bring logout from azure to microsoft (#1202) Co-authored-by: Vuong V --- Provider.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Provider.php b/Provider.php index c795175..6c8ce35 100644 --- a/Provider.php +++ b/Provider.php @@ -61,6 +61,22 @@ protected function getTokenUrl() return sprintf('https://login.microsoftonline.com/%s/oauth2/v2.0/token', $this->getConfig('tenant', 'common')); } + /** + * Return the logout endpoint with an optional post_logout_redirect_uri query parameter. + * + * @param string|null $redirectUri The URI to redirect to after logout, if provided. + * If not provided, no post_logout_redirect_uri parameter will be included. + * @return string The logout endpoint URL. + */ + public function getLogoutUrl(?string $redirectUri = null) + { + $logoutUrl = sprintf('https://login.microsoftonline.com/%s/oauth2/logout', $this->getConfig('tenant', 'common')); + + return $redirectUri === null ? + $logoutUrl : + $logoutUrl.'?'.http_build_query(['post_logout_redirect_uri' => $redirectUri], '', '&', $this->encodingType); + } + /** * {@inheritdoc} */