Download the PHP package overtrue/keycloak-rest-api-client-php without Composer
On this page you can find all versions of the php package overtrue/keycloak-rest-api-client-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download overtrue/keycloak-rest-api-client-php
More information about overtrue/keycloak-rest-api-client-php
Files in overtrue/keycloak-rest-api-client-php
Package keycloak-rest-api-client-php
Short Description PHP client to interact with Keycloak's Admin REST API.
License mit
Informations about the package keycloak-rest-api-client-php
Keycloak Admin REST API Client
PHP client to interact with Keycloak's Admin REST API.
Inspired by keycloak/keycloak-nodejs-admin-client.
This is a fork of fschmtt/keycloak-rest-api-client-php
Installation
Install via Composer:
Usage
Example:
will print e.g.
More examples can be found in the examples directory.
Customization
Custom representations & resources
You can register and use custom resources by providing your own representations and resources, e.g.:
By extending the Resource
class, you have access to both the QueryExecutor
and CommandExecutor
.
The CommandExecutor
is designed to run state-changing commands against the server (without returning a response);
the QueryExecutor
allows fetching resources and representations from the server.
To use your custom resource, pass the fully-qualified class name (FQCN) to the Keycloak::resource()
method.
It provides you with an instance of your resource you can then work with:
Available Resources
Attack Detection
Endpoint | Response | API |
---|---|---|
DELETE /admin/realms/{realm}/attack-detection/brute-force/users |
ResponseInterface | AttackDetection::clear() |
GET /admin/realms/{realm}/attack-detection/brute-force/users/{userId} |
Map | AttackDetection::userStatus() |
DELETE /admin/realms/{realm}/attack-detection/brute-force/users/{userId} |
ResponseInterface | AttackDetection::clearUser() |
Clients
Endpoint | Response | API |
---|---|---|
GET /admin/realms/{realm}/clients |
ClientCollection | Clients::all() |
GET /admin/realms/{realm}/clients/{client-uuid} |
Client | Clients::get() |
PUT /admin/realms/{realm}/clients/{client-uuid} |
Client | Clients::update() |
POST /admin/realms/{realm}/clients |
Client | Clients::import() |
GET /admin/realms/{realm}/clients/{client-uuid}/client-secret |
Client | Clients::getClientSecret() |
Groups
Endpoint | Response | API |
---|---|---|
GET /admin/realms/{realm}/groups |
GroupCollection | Groups::all() |
GET /admin/realms/{realm}/groups/{id}/children |
GroupCollection | Groups::children() |
GET /admin/realms/{realm}/groups/{id}/members |
UserCollection | Groups::members() |
GET /admin/realms/{realm}/groups/{id} |
Group | Groups::get() |
PUT /admin/realms/{realm}/groups/{id} |
ResponseInterface | Groups::update() |
POST /admin/realms/{realm}/groups |
ResponseInterface | Groups::create() |
POST /admin/realms/{realm}/groups/{id}/children |
ResponseInterface | Groups::create() |
DELETE /admin/realms/{realm}/groups |
ResponseInterface | Groups::delete() |
GET /admin/realms/{realm}/group-by-path/{path} |
Group | Groups::byPath() |
Organizations
Endpoint | Response | API |
---|---|---|
GET /admin/realms/{realm}/organizations |
OrganizationCollection | Organizations::all() |
GET /admin/realms/{realm}/organizations/{id} |
Organization | Organizations::get() |
POST /admin/realms/{realm}/organizations |
ResponseInterface | Organizations::create() |
DELETE /admin/realms/{realm}/organizations/{id} |
ResponseInterface | Organizations::delete() |
GET /admin/realms/{realm}/organizations/{id}/members |
MemberCollection | Organizations::members() |
GET /admin/realms/{realm}/organizations/{id}/members/count |
ResponseInterface | Organizations::membersCount() |
POST /admin/realms/{realm}/organizations/{id}/members |
ResponseInterface | Organizations::addMember() |
DELETE /admin/realms/{realm}/organizations/{id}/members/{member-id} |
ResponseInterface | Organizations::deleteMember() |
GET /admin/realms/{realm}/organizations/{id}/members/{member-id}/orgainzations |
OrganizationCollection | Organizations::memberOrganizations() |
POST /admin/realms/{realm}/organizations/{id}/members/invite-user |
ResponseInterface | Organizations::inviteUser() |
POST /admin/realms/{realm}/organizations/{id}/members/invite-existing-user |
ResponseInterface | Organizations::inviteExistingUser() |
POST /admin/realms/{realm}/organizations/{id}/identity-providers |
ResponseInterface | Organizations::linkIdp() |
DELETE /admin/realms/{realm}/organizations/{id}/identity-providers/{alias} |
ResponseInterface | Organizations::unlinkIdp() |
Realms Admin
Endpoint | Response | API |
---|---|---|
POST /admin/realms |
Realm | Realms::import() |
GET /admin/realms |
RealmCollection | Realms::all() |
PUT /admin/realms/{realm} |
Realm | Realms::update() |
DELETE /admin/realms/{realm} |
ResponseInterface | Realms::delete() |
GET /admin/realms/{realm}/admin-events |
array |
Realms::adminEvents() |
GET /admin/realms/{realm}/keys |
KeysMetadata | Realms::keys() |
DELETE /admin/realms/{realm}/admin-events |
ResponseInterface | Realms::deleteAdminEvents() |
POST /admin/realms/{realm}/clear-keys-cache |
ResponseInterface | Realms::clearKeysCache() |
POST /admin/realms/{realm}/clear-realm-cache |
ResponseInterface | Realms::clearRealmCache() |
POST /admin/realms/{realm}/clear-user-cache |
ResponseInterface | Realms::clearUserCache() |
Users
Endpoint | Response | API |
---|---|---|
GET /admin/realms/{realm}/users |
UserCollection | Users::all() |
POST /admin/realms/{realm}/users |
ResponseInterface | Users::create() |
GET /admin/realms/{realm}/users/{userId} |
User | Users::get() |
PUT /admin/realms/{realm}/users/{userId} |
ResponseInterface | Users::update() |
DELETE /admin/realms/{realm}/users/{userId} |
ResponseInterface | Users::delete() |
GET /admin/realms/{realm}/users |
UserCollection | Users::search() |
PUT /{realm}/users/{id}/groups/{groupId} |
ResponseInterface | Users::joinGroup() |
DELETE /{realm}/users/{id}/groups/{groupId} |
ResponseInterface | Users::leaveGroup() |
GET /{realm}/users/{id}/groups |
GroupCollection | Users::retrieveGroups() |
GET /{realm}/users/{id}/role-mappings/realm |
RoleCollection | Users::retrieveRealmRoles() |
GET /{realm}/users/{id}/role-mappings/realm/available |
RoleCollection | Users::retrieveAvailableRealmRoles() |
POST /{realm}/users/{id}/role-mappings/realm |
ResponseInterface | Users::addRealmRoles() |
DELETE /{realm}/users/{id}/role-mappings/realm |
ResponseInterface | Users::removeRealmRoles() |
PUT /{realm}/users/{id}/execute-actions-email |
ResponseInterface | Users::executeActionsEmail() |
GET /admin/realms/{realm}/users/{userId}/credentials |
CredentialCollection | Users::credentials() |
Roles
Endpoint | Response | API |
---|---|---|
GET /admin/realms/{realm}/roles |
RoleCollection | Roles::all() |
GET /admin/realms/{realm}/roles/{roleName} |
Role | Roles::get() |
POST /admin/realms/{realm}/roles |
ResponseInterface | Roles::create() |
DELETE /admin/realms/{realm}/roles/{roleName} |
ResponseInterface | Roles::delete() |
Root
Endpoint | Response | API |
---|---|---|
GET /admin/serverinfo |
ServerInfo | ServerInfo::get() |
Local development and testing
Run docker compose up -d keycloak
to start a local Keycloak instance listening on http://localhost:8080.
Run your script (e.g. examples/serverinfo.php) from within the php
container:
Composer scripts
analyze
: Run phpstan analysisfix
: Fix coding style issues (Laravel pint)test
: Run unit and integration teststest:unit
: Run unit teststest:integration
: Run integration tests (requires a fresh and running Keycloak instance)
All versions of keycloak-rest-api-client-php with dependencies
ext-json Version *
guzzlehttp/guzzle Version ^7.9
lcobucci/jwt Version ^5.5
symfony/serializer Version ^7.2
symfony/property-access Version ^7.2