Commit 7cf7c2107bd5788d369e3f33e354f53795831691
1 parent
b5c6d0399d
Exists in
master
bug fixes sso callback
Showing 1 changed file with 16 additions and 3 deletions Side-by-side Diff
SsoClientLibrary.php
... | ... | @@ -34,7 +34,6 @@ |
34 | 34 | } |
35 | 35 | |
36 | 36 | public function ssoRequest() { |
37 | - // $state = Str::random(40); | |
38 | 37 | $state = base64_encode(random_bytes(40)); |
39 | 38 | $query = http_build_query([ |
40 | 39 | 'client_id' => $this->clientId, |
... | ... | @@ -50,7 +49,11 @@ |
50 | 49 | } |
51 | 50 | |
52 | 51 | public function ssoCallback() { |
53 | - if (isset($_GET['code']) && !empty(($_GET['code']))) { | |
52 | + $url = parse_url($this->redirectUri); | |
53 | + $code = str_replace($url['path'] . '?code=','',$_SERVER['REQUEST_URI']); | |
54 | + $code = explode('&',$code); | |
55 | + $code = $code[0] ?? ''; | |
56 | + if ($code != '') { | |
54 | 57 | $_access_token = ''; |
55 | 58 | $_errors = ''; |
56 | 59 | |
... | ... | @@ -59,7 +62,7 @@ |
59 | 62 | 'client_id' => $this->clientId, |
60 | 63 | 'client_secret' => $this->clientSecret, |
61 | 64 | 'redirect_uri' => $this->redirectUri, |
62 | - 'code' => $_GET['code'], | |
65 | + 'code' => $code, | |
63 | 66 | ]; |
64 | 67 | $arr_token = $this->__runCurl('POST', $this->targetUri."oauth/token", $_posts); |
65 | 68 | return $arr_token; |
... | ... | @@ -122,6 +125,16 @@ |
122 | 125 | return $error; |
123 | 126 | } |
124 | 127 | die('Something went wrong, please trace back your action!'); |
128 | + } | |
129 | + | |
130 | + public function ssoLogout($url_back = '') { | |
131 | + $query = http_build_query([ | |
132 | + 'url_back' => $url_back, | |
133 | + ]); | |
134 | + | |
135 | + $_url = $this->targetUri ."sso/logout?" . $query; | |
136 | + header("Location: " . $_url); | |
137 | + die(); | |
125 | 138 | } |
126 | 139 | |
127 | 140 | } |