AIRAVATA-2342 Support Keycloak OIDC logout
Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/64362fe8 Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/64362fe8 Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/64362fe8 Branch: refs/heads/develop Commit: 64362fe8d56e2cc6396f84bf6de422a06fbe1c21 Parents: a37c5aa Author: Marcus Christie <[email protected]> Authored: Tue Mar 28 17:06:41 2017 -0400 Committer: Marcus Christie <[email protected]> Committed: Tue Mar 28 17:06:41 2017 -0400 ---------------------------------------------------------------------- app/controllers/AccountController.php | 13 +++++-------- app/libraries/Keycloak/Keycloak.php | 9 +++++++++ 2 files changed, 14 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/64362fe8/app/controllers/AccountController.php ---------------------------------------------------------------------- diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index 77b1feb..7900c7c 100644 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -465,14 +465,11 @@ class AccountController extends BaseController public function logout() { -// Session::flush(); -// if(Config::get('pga_config.wsis')['auth-mode'] == "oauth"){ -// return Redirect::away(WSIS::getOAuthLogoutUrl()); -// } -// return Redirect::to('home'); - - Session::flush(); - return Redirect::to('home'); + Session::flush(); + if(Config::get('pga_config.wsis')['oauth-grant-type'] == "authorization_code"){ + return Redirect::away(Keycloak::getOAuthLogoutUrl(URL::to("/"))); + } + return Redirect::to('home'); } public function allocationRequestView(){ http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/64362fe8/app/libraries/Keycloak/Keycloak.php ---------------------------------------------------------------------- diff --git a/app/libraries/Keycloak/Keycloak.php b/app/libraries/Keycloak/Keycloak.php index 0bfec52..8c9c1a1 100644 --- a/app/libraries/Keycloak/Keycloak.php +++ b/app/libraries/Keycloak/Keycloak.php @@ -168,6 +168,15 @@ class Keycloak { } /** + * Function to get the OAuth logout url + */ + public function getOAuthLogoutUrl($redirect_uri) { + $config = $this->getOpenIDConnectDiscoveryConfiguration(); + $logout_endpoint = $config->end_session_endpoint; + return $logout_endpoint . '?redirect_uri=' . rawurlencode($redirect_uri); + } + + /** * Function to list users * * @return Array of usernames
