PHP code example of developerawam / omni-central-auth

1. Go to this page and download the library: Download developerawam/omni-central-auth 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/ */

    

developerawam / omni-central-auth example snippets


use Laravel\Passport\HasApiTokens;
use Laravel\Fortify\TwoFactorAuthenticatable;

class User extends Authenticatable
{
    use HasApiTokens, TwoFactorAuthenticatable;

    protected $fillable = [
        'name',
        'email',
        'password',
        'role',      // 

'views' => false,

use DeveloperAwam\OmniCentralAuth\Http\Controllers\Server\AuthorizationController;

$payload = AuthorizationController::encryptPayload([
    'omni_id' => $user->id,
    'name'    => $user->name,
    'email'   => $user->email,
], $signingKey);

use DeveloperAwam\OmniCentralAuth\Http\Controllers\Server\AuthorizationController;

// $ssoData is the encrypted payload string from the callback URL query parameter (?sso_data=...)
// received via $request->query('sso_data') in the CallbackController.
//
// $signingKey is the shared secret from config('omni-central-auth.client.signing_key')
// which reads from the OMNI_CENTRAL_SIGNING_KEY env variable.
// This MUST be identical to the key used on the SSO Server.

$ssoData    = $request->query('sso_data');
$signingKey = config('omni-central-auth.client.signing_key');

$userData = AuthorizationController::decryptPayload($ssoData, $signingKey);
// Returns: ['omni_id' => 1, 'name' => '...', 'email' => '...', 'avatar' => null, 'timestamp' => 1234567890]
// Returns: null if payload is invalid or tampered
bash
php artisan omni:install
bash
php artisan migrate
bash
php artisan vendor:publish --provider="Laravel\Fortify\FortifyServiceProvider"
bash
php artisan migrate