PHP code example of overtrue / laravel-keycloak-guard
1. Go to this page and download the library: Download overtrue/laravel-keycloak-guard 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/ */
overtrue / laravel-keycloak-guard example snippets
'defaults' => [
'guard' => 'api', // Set the default guard to 'api'.
'passwords' => 'users',
],
'guards' => [
'api' => [
'driver' => 'keycloak', // Use 'keycloak' as the driver for the 'api' guard.
'provider' => 'users',
],
],
// public endpoints
Route::get('/hello', function () {
return ':)';
});
// protected endpoints
Route::group(['middleware' => 'auth:api'], function () {
Route::get('/protected-endpoint', 'SecretController@index');
// ...
});
// keycloak.php
'input_key' => 'api_token'
$token = Auth::token() // or Auth::user()->token()