diff --git a/SsoClientLibrary.php b/SsoClientLibrary.php index bca228b..45f14f9 100755 --- a/SsoClientLibrary.php +++ b/SsoClientLibrary.php @@ -34,7 +34,6 @@ class SsoClientLibrary { } public function ssoRequest() { - // $state = Str::random(40); $state = base64_encode(random_bytes(40)); $query = http_build_query([ 'client_id' => $this->clientId, @@ -50,7 +49,11 @@ class SsoClientLibrary { } public function ssoCallback() { - if (isset($_GET['code']) && !empty(($_GET['code']))) { + $url = parse_url($this->redirectUri); + $code = str_replace($url['path'] . '?code=','',$_SERVER['REQUEST_URI']); + $code = explode('&',$code); + $code = $code[0] ?? ''; + if ($code != '') { $_access_token = ''; $_errors = ''; @@ -59,7 +62,7 @@ class SsoClientLibrary { 'client_id' => $this->clientId, 'client_secret' => $this->clientSecret, 'redirect_uri' => $this->redirectUri, - 'code' => $_GET['code'], + 'code' => $code, ]; $arr_token = $this->__runCurl('POST', $this->targetUri."oauth/token", $_posts); return $arr_token; @@ -124,6 +127,16 @@ class SsoClientLibrary { die('Something went wrong, please trace back your action!'); } + public function ssoLogout($url_back = '') { + $query = http_build_query([ + 'url_back' => $url_back, + ]); + + $_url = $this->targetUri ."sso/logout?" . $query; + header("Location: " . $_url); + die(); + } + } ?>