Name | Last Update | Last Commit 068a6584182 – add check SSO' | history |
---|---|---|---|
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
|||
![]() |
README.md
SampleSso
SAMPLE SSO
Cara Install
Via Terminal:
composer install
chmod -R guo+w storage
cp .env.example .env
Atur pengaturan database pada file .env
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=grandmaster
DB_USERNAME=root
DB_PASSWORD=
Atur pengaturan SSO Client ID pada file .env
SSO_CLIENT_ID= #3rd Party client Id (client id dari aplikasi SSO)
SSO_CLIENT_SECRET= #3rd Party client secret (client secret dari aplikasi SSO)
SSO_REDIRECT_URI= #3rd Party url redirect or url to handle callback (url redirect aplikasi anda jika berhasil login SSO)
SSO_TARGET_URI="https://sso.riau.go.id/" #SSO Riau portal
Migrate database dan seeder
php artisan migrate --seed #username dan password akan muncul setelah migrate
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
}
}
}