PHP code example of keloola / keloola-sso-authorize

1. Go to this page and download the library: Download keloola/keloola-sso-authorize 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/ */

    

keloola / keloola-sso-authorize example snippets


php artisan vendor:publish --tag=keloola-auth-config

KELOOLA_AUTH_APP_ID=xxx //app id
KELOOLA_AUTH_SSO_HOST=https://accounts.keloola.xyz
KELOOLA_AUTH_CACHE_EXPIRED=60
KELOOLA_AUTH_ACCOUNTING_HOST=host api accounting
KELOOLA_AUTH_ACCOUNTING_ENCRYPT=false //jika accounting tidak di encrypt response dan request nya
KELOOLA_AUTH_ACCOUNTING_APP_KEY=xxx //jika encrypt true ini 


Setup Middleware Sso and Accounting

You can use on global middlware 

Location : project-laravel/bootstrap/app.php

use Keloola\KeloolaSsoAuthorize\Http\Middleware\KeloolaAuthMiddleware;

->withMiddleware(function (Middleware $middleware) {
       $middleware->api(append: [
            KeloolaAuthMiddleware::class,
        ]);
})

If you want to connect the keloola accounting , you must be use KeloolaAuthAccountingMiddleware

use Keloola\KeloolaSsoAuthorize\Http\Middleware\KeloolaAuthAccountingMiddleware;

Add before KeloolaAuthMiddleware::class


->withMiddleware(function (Middleware $middleware) {
       $middleware->api(append: [
            KeloolaAuthMiddleware::class,
            KeloolaAuthAccountingMiddleware::class, <----- disini
        ]);
})

or via routes

Route::middleware([KeloolaAuthMiddleware::class, KeloolaAuthAccountingMiddleware::class])
->group(function () {
    Route::get('/example', function () {
        return 'OK';
    });
});




Sso User Data 
$request->sso_user;

Accunting Data
$request->accounting_user