Commit dde60e7b2ca0380a4147137e80eed9992b6bfdab
1 parent
21e3db6176
Exists in
master
use namespace
Showing 1 changed file with 1 additions and 0 deletions Inline Diff
README.md
| 1 | ## SSO Riau | 1 | ## SSO Riau |
| 2 | SSO Riau | 2 | SSO Riau |
| 3 | 3 | ||
| 4 | Construct: | 4 | Construct: |
| 5 | ---- | 5 | ---- |
| 6 | 6 | ||
| 7 | ```$php | 7 | ```$php |
| 8 | $this->clientId = ''; // 3rd Party client Id | 8 | $this->clientId = ''; // 3rd Party client Id |
| 9 | $this->clientSecret = ''; // 3rd Party client secret | 9 | $this->clientSecret = ''; // 3rd Party client secret |
| 10 | $this->redirectUri = ''; // 3rd Party url redirect or url to handle callback | 10 | $this->redirectUri = ''; // 3rd Party url redirect or url to handle callback |
| 11 | $this->targetUri = 'https://sso.riau.go.id/'; // SSO Riau portal | 11 | $this->targetUri = 'https://sso.riau.go.id/'; // SSO Riau portal |
| 12 | 12 | ||
| 13 | ``` | 13 | ``` |
| 14 | Check SSO session : | 14 | Check SSO session : |
| 15 | ---- | 15 | ---- |
| 16 | 16 | ||
| 17 | ```$php | 17 | ```$php |
| 18 | use SsoRiau\SsoClientLibrary; | 18 | use SsoRiau\SsoClientLibrary; |
| 19 | $objSso = new SsoClientLibrary(); | 19 | $objSso = new SsoClientLibrary(); |
| 20 | $objSso->ssoRequest(); | 20 | $objSso->ssoRequest(); |
| 21 | 21 | ||
| 22 | ``` | 22 | ``` |
| 23 | Consume SSO session : | 23 | Consume SSO session : |
| 24 | ---- | 24 | ---- |
| 25 | 25 | ||
| 26 | ```$php | 26 | ```$php |
| 27 | use SsoRiau\SsoClientLibrary; | ||
| 27 | $objSso = new SsoClientLibrary(); | 28 | $objSso = new SsoClientLibrary(); |
| 28 | $data_access_token = $objSso->ssoCallback(); | 29 | $data_access_token = $objSso->ssoCallback(); |
| 29 | if (!empty($data_access_token)) { | 30 | if (!empty($data_access_token)) { |
| 30 | $data_access_token = json_decode($data_access_token); | 31 | $data_access_token = json_decode($data_access_token); |
| 31 | $access_token = $data_access_token->access_token; // store access_token within the session if needed? | 32 | $access_token = $data_access_token->access_token; // store access_token within the session if needed? |
| 32 | } | 33 | } |
| 33 | 34 | ||
| 34 | if ($access_token != '') { | 35 | if ($access_token != '') { |
| 35 | //fetch ssoUserInfo | 36 | //fetch ssoUserInfo |
| 36 | $ssoUserInfo = $objSso->ssoUserInfo($access_token); | 37 | $ssoUserInfo = $objSso->ssoUserInfo($access_token); |
| 37 | $ssoUserInfo = json_decode($ssoUserInfo); | 38 | $ssoUserInfo = json_decode($ssoUserInfo); |
| 38 | $email = $ssoUserInfo->email; | 39 | $email = $ssoUserInfo->email; |
| 39 | } | 40 | } |
| 40 | 41 | ||
| 41 | ``` | 42 | ``` |