From 068a658418258f25e302175eeada0ecf3eb4c7c5 Mon Sep 17 00:00:00 2001 From: oji Date: Fri, 5 Aug 2022 15:52:42 +0700 Subject: [PATCH] add check SSO' --- README.md | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 302d22c..a41fbc9 100644 --- a/README.md +++ b/README.md @@ -33,4 +33,42 @@ Migrate database dan seeder ``` php artisan migrate --seed #username dan password akan muncul setelah migrate -``` \ No newline at end of file +``` + +Check SSO session : app\Http\Controllers\Sso.php + +``` +public function check() +{ + $objSso = new SsoClientLibrary(); + $objSso->ssoRequest(); +} + +``` + +Consume SSO session : app\Http\Controllers\Sso.php + +``` +public function callback(Request $request) +{ + if (isset($request->code) && $request->code != '') { + $objSso = new SsoClientLibrary(); + $data_access_token = $objSso->ssoCallback(); + if (!empty($data_access_token)) { + $data_access_token = json_decode($data_access_token); + $access_token = $data_access_token->access_token; // store access_token within the session if needed? + } + + if ($access_token != '') { + //fetch ssoUserInfo + $ssoUserInfo = $objSso->ssoUserInfo($access_token); + $ssoUserInfo = json_decode($ssoUserInfo); + + // check if sso_email already mapped or not + $user = User::where('sso_email', $ssoUserInfo->email)->first(); + // mapping to local database + } + } +} + +``` -- 2.7.4