Commit 068a658418258f25e302175eeada0ecf3eb4c7c5
1 parent
a15ede0912
Exists in
master
add check SSO'
Showing 1 changed file with 39 additions and 1 deletions Side-by-side Diff
README.md
... | ... | @@ -34,4 +34,42 @@ |
34 | 34 | ``` |
35 | 35 | php artisan migrate --seed #username dan password akan muncul setelah migrate |
36 | 36 | ``` |
37 | + | |
38 | +Check SSO session : app\Http\Controllers\Sso.php | |
39 | + | |
40 | +``` | |
41 | +public function check() | |
42 | +{ | |
43 | + $objSso = new SsoClientLibrary(); | |
44 | + $objSso->ssoRequest(); | |
45 | +} | |
46 | + | |
47 | +``` | |
48 | + | |
49 | +Consume SSO session : app\Http\Controllers\Sso.php | |
50 | + | |
51 | +``` | |
52 | +public function callback(Request $request) | |
53 | +{ | |
54 | + if (isset($request->code) && $request->code != '') { | |
55 | + $objSso = new SsoClientLibrary(); | |
56 | + $data_access_token = $objSso->ssoCallback(); | |
57 | + if (!empty($data_access_token)) { | |
58 | + $data_access_token = json_decode($data_access_token); | |
59 | + $access_token = $data_access_token->access_token; // store access_token within the session if needed? | |
60 | + } | |
61 | + | |
62 | + if ($access_token != '') { | |
63 | + //fetch ssoUserInfo | |
64 | + $ssoUserInfo = $objSso->ssoUserInfo($access_token); | |
65 | + $ssoUserInfo = json_decode($ssoUserInfo); | |
66 | + | |
67 | + // check if sso_email already mapped or not | |
68 | + $user = User::where('sso_email', $ssoUserInfo->email)->first(); | |
69 | + // mapping to local database | |
70 | + } | |
71 | + } | |
72 | +} | |
73 | + | |
74 | +``` |