diff --git a/src/Microsoft/Provider.php b/src/Microsoft/Provider.php index c79517594..6c8ce359b 100644 --- a/src/Microsoft/Provider.php +++ b/src/Microsoft/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} */