This package supports Keycloak administrator client API, authenticating with username and password or using the security key (client_secret)
srlopes/laravel-keycloak-admin is a Laravel package for this package supports keycloak administrator client api, authenticating with username and password or using the security key (client_secret).
It currently has 0 GitHub stars and 2.021 downloads on Packagist (latest version 0.1.2).
Install it with composer require srlopes/laravel-keycloak-admin.
Discover more Laravel packages by srlopes
or browse all Laravel packages to compare alternatives.
Last updated
composer require srlopes/laravel-keycloak-admin
Add these environment variables to your .env :
KEYCLOAK_ADMIN_BASE_URL=http://keycloak-domain.example/auth
KEYCLOAK_ADMIN_REALM_LOGIN=
KEYCLOAK_ADMIN_REALM=
# Choose to fill in user name and password or client_id and client_secret
KEYCLOAK_ADMIN_USERNAME=
KEYCLOAK_ADMIN_PASSWORD=
KEYCLOAK_ADMIN_CLIENT_ID=
KEYCLOAK_ADMIN_CLIENT_SECRET= # clients -> your_client -> credentials
KEYCLOAK_ADMIN_BASE_URL_REALM=${KEYCLOAK_BASE_URL}/admin/realms/${KEYCLOAK_ADMIN_REALM}
Go to clients -> your_client -> Service Account then select realm-managment
from Client Roles list and assign realm-admin to client.
Package has provided services as below :
Publish the config file:
php artisan vendor:publish --provider="KeycloakAdm\KeycloakAdminServiceProvider"
All api's are in config\keycloakAdmin.php
For every api just call api name as method on related service .
example:
use KeycloakAdm\Facades\KeycloakAdmin;
KeycloakAdm::user()->create([
'body' => [ // https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_userrepresentation
'username' => 'foo'
]
]);
KeycloakAdmin::user()->all([
'query' => [
'email' => '[email protected]'
]
])
KeycloakAdm::user()->update([
'id' => 'user_id',
'body' => [ // https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_userrepresentation
'username' => 'foo'
]
]);
KeycloakAdm::role()->get([
'id' => 'role_id'
]);
All other api calls are same as examples just need to see required parameters for every api in https://www.keycloak.org/docs-api/11.0/rest-api/index.html