PHP code example of moko-github / kerberos-auth
1. Go to this page and download the library: Download moko-github/kerberos-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/ */
moko-github / kerberos-auth example snippets
// config/kerberos.php
'user_model' => \App\Models\Account::class,
// config/kerberos.php
'redirects' => [
'success' => 'home', // après authentification réussie
'login' => 'auth.login', // route de connexion / fallback
],
// config/kerberos.php
'excluded_routes' => [
'admin.*', // toutes les routes d'admin
'api.*', // toutes les routes API
'webhook.pay', // une route spécifique
],
// config/kerberos.php
'layout' => 'layouts.auth', // layout Laravel standard
'layout' => 'components.layouts.app', // layout Livewire Volt
'layout' => 'layouts.guest', // votre propre layout guest
'role_check' => [
'strategy' => 'column',
'column' => 'role_id', // colonne à tester
'operator' => 'is_not_null', // 'is_not_null' (défaut) | 'is_null'
],
'role_check' => [
'strategy' => 'relation',
'relation' => 'roles',
],
'role_check' => [
'strategy' => 'callable',
'callable' => \App\Kerberos\MyAccessCheck::class,
],
class MyAccessCheck implements UserAccessCheckInterface
{
public function check(User $user): bool
{
return $user->deleted_at === null && $user->department !== 'EXTERN';
}
}
'install' => [
'run_seeders' => false,
'seed_roles' => false,
],
'locale' => 'fr',
'fallback_locale' => 'en',
bash
php artisan kerberos:install
bash
php artisan kerberos:install --no-roles # sans système de rôles
php artisan kerberos:install --no-seed # migrations uniquement, sans seeders
bash
php artisan vendor:publish --tag=kerberos-config
bash
php artisan vendor:publish --tag=kerberos-views
# → resources/views/vendor/kerberos-auth/layouts/guest.blade.php
bash
php artisan vendor:publish --tag=kerberos-views
├── layouts/
│ └── guest.blade.php # layout par défaut des pages Kerberos
└── livewire/auth/
├── access-denied.blade.php
├── request-access.blade.php
├── simulate-kerberos.blade.php
└── simulation-banner.blade.php
bash
php artisan vendor:publish --tag=kerberos-lang
├── en/
│ └── kerberos.php
└── fr/
└── kerberos.php
bash
composer update moko-github/kerberos-auth
php artisan migrate
bash
php artisan kerberos:install # Installation initiale (interactif)
php artisan kerberos:install --no-seed # Installation sans seeders
php artisan kerberos:install --no-roles # Installation sans RolesSeeder
php artisan kerberos:purge-attempts # Purge les tentatives anciennes
bash
php artisan vendor:publish --tag=kerberos-config # config/kerberos.php
php artisan vendor:publish --tag=kerberos-views # vues + layout guest
php artisan vendor:publish --tag=kerberos-seeders # seeders
php artisan vendor:publish --tag=kerberos-lang # traductions EN/FR