PHP code example of omniglies / laravel-sso-client

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

    

omniglies / laravel-sso-client example snippets


return [
    // User model to use for authentication
    'user_model' => 'App\\Models\\User',
    
    // Default role for new SSO users (, 'address', 'nip_pbb', 
        'kd_propinsi', 'kd_dati2', 'kd_kecamatan', 'kd_kelurahan'
    ],
    
    // Redirect path after successful login
    'redirect_after_login' => '/home',
    
    // Route configuration
    'route_prefix' => 'sso',
    'middleware' => ['web'],
];

use Omniglies\LaravelSsoClient\Services\SsoUserService;

$ssoService = new SsoUserService();

// Search users ( OAuth server
$newUser = $ssoService->withToken($adminToken)->createUser([
    'name' => 'John Doe',
    'email' => '[email protected]',
    'username' => 'johndoe',
    'password' => 'password'
]);

// Sync local user with OAuth server
$ssoService->syncLocalUser($user);
bash
php artisan sso:install
bash
php artisan vendor:publish --tag=sso-client-config
bash
php artisan vendor:publish --tag=sso-client-migrations
bash
php artisan migrate
blade
{{-- SSO Login Button --}}
<a href="{{ route('sso.redirect') }}" class="btn btn-primary">
    Login with SSO
</a>

{{-- SSO Logout Button --}}
<form method="POST" action="{{ route('sso.logout') }}">
    @csrf
    <button type="submit" class="btn btn-secondary">
        Logout (SSO)
    </button>
</form>

{{-- Local Logout Only --}}
<form method="POST" action="{{ route('sso.local-logout') }}">
    @csrf
    <button type="submit" class="btn btn-secondary">
        Logout (Local Only)
    </button>
</form>