PHP code example of sksso / smartsso-postgresql

1. Go to this page and download the library: Download sksso/smartsso-postgresql library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sksso / smartsso-postgresql example snippets

HTML+PHP
private $sdkSSO;

public function __construct() {
    //inisialisasi konfigurasi SSO
    $this->sdkSSO = new SDKlrvlSSO();
    $this->sdkSSO->setEnv([ALIAS_ID], [SECRET_KEY_BODY], [SECRET_KEY_URL]);
    ....
HTML+PHP
$this->sdkSSO->loginPage();
HTML+PHP
$this->sdkSSO->setDbConfig([HOST], [DB_USER], [DB_PASS], [DB_NAME]);
HTML+PHP
$this->sdkSSO->syncDbTable($dataTable);
HTML+PHP
use sksso\SDKlrvlSSO;

class NamaController extends Controller
{
private $sdkSSO;

public function __construct() {
    //inisialisasi konfigurasi SSO
    $this->sdkSSO = new SDKlrvlSSO();
          $dataTable = 
         [
            "nama_table" => "users",
            "user_key" => "nik",
            "field_table" => [
                "id" => NULL,
                "username" => NULL,
                "password" => NULL,
                "nama_lengkap" => "name",
                "alamat" => NULL,
                "email" => "email",
                "nik" => "nik",
                "created_by" => NULL,
                "created_date" => "created_at"
            ]
    ];
    $this->sdkSSO->setEnv([ALIAS_ID], [SECRET_KEY_BODY], [SECRET_KEY_URL]);
    $this->sdkSSO->setDbConfig([HOST], [DB_USER], [DB_PASS], [DB_NAME]);
    $this->sdkSSO->syncDbTable($dataTable);
}
HTML+PHP
    public function ekstrakData(){
        $data = file_get_contents('php://input');
        
        return $this->sdkSSO->ekstrakDataCredentials($data);
    }
HTML+PHP
    public function login(Request $request, $param){
        $dataUsers = $this->sdkSSO->cekTiket($param);
        if($dataUsers) //output data kredensial pengguna format array 
        {
            Auth::loginUsingId($dataUsers['id']); //auth login by ID
            return redirect()->route('home'); //kondisi setelah user dapat login
        }
    }
HTML+PHP
 $this->sdkSSO->logout();