PHP code example of grupo-cometa / keycloak
1. Go to this page and download the library: Download grupo-cometa/keycloak 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/ */
grupo-cometa / keycloak example snippets
$routerMiddleware = [
'auth' => GrupoCometa\Keycloak\Middlewares\Authenticate::class,
'permission' => GrupoCometa\Keycloak\Middlewares\Authorization::class
...
];
$router->post('/', [
'uses' => 'AuthController@store'
]);
$app->register(GrupoCometa\Keycloak\Providers\KeycloakServiceProvider::class);
$app->routeMiddleware([
'auth' => GrupoCometa\Keycloak\Middlewares\Authenticate::class,
'permission' => GrupoCometa\Keycloak\Middlewares\Authorization::class
]);
$router->get('/keycloak', [
'uses' => "KeycloakController@index",
'middleware' => ['auth', 'permission:users#list-all']
]);
/**
* @return \Illuminate\Contracts\Auth\Authenticatable|null
**/
Illuminate\Support\Facades\Auth::user();
/**
* @param array<App\Model\Role>| Role
* @return bool
**/
Illuminate\Support\Facades\Auth::hasRoles(Role::admin);
## OR
Illuminate\Support\Facades\Auth::hasRoles([Role::admin, Role::gestor]);
/**
* @return array
**/
Illuminate\Support\Facades\Auth::allPermission();
/**
* @return array
**/
Illuminate\Support\Facades\Auth::getRoles();
/**
* @param string
* @return mixed
**/
Illuminate\Support\Facades\Auth::getAttribute("name");