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.
Caching
The Keycloak client supports powerful caching based on PSR-16 (Simple Cache) standard:
For detailed caching configuration and usage, see CACHE.md.
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} |
StringMap | 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/{clientUuid} |
ClientRepresentation | Clients::get() |
POST /admin/realms/{realm}/clients |
ClientRepresentation | Clients::import() |
PUT /admin/realms/{realm}/clients/{clientUuid} |
ClientRepresentation | Clients::update() |
DELETE /admin/realms/{realm}/clients/{clientUuid} |
ResponseInterface | Clients::delete() |
GET /admin/realms/{realm}/clients/{clientUuid}/user-sessions |
array | Clients::getUserSessions() |
GET /admin/realms/{realm}/clients/{clientUuid}/client-secret |
Credential | Clients::getClientSecret() |
Groups
| Endpoint | Response | API |
|---|---|---|
GET /admin/realms/{realm}/groups |
GroupCollection | Groups::all() |
GET /admin/realms/{realm}/group-by-path/{path} |
Group | Groups::byPath() |
GET /admin/realms/{realm}/groups/{groupId}/children |
GroupCollection | Groups::children() |
GET /admin/realms/{realm}/groups/{groupId}/members |
UserCollection | Groups::members() |
GET /admin/realms/{realm}/groups/{groupId} |
Group | Groups::get() |
POST /admin/realms/{realm}/groups |
Group | Groups::create() |
POST /admin/realms/{realm}/groups/{groupId}/children |
Group | Groups::createChild() |
PUT /admin/realms/{realm}/groups/{groupId} |
ResponseInterface | Groups::update() |
DELETE /admin/realms/{realm}/groups/{groupId} |
ResponseInterface | Groups::delete() |
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 |
Organization | Organizations::create() |
PUT /admin/realms/{realm}/organizations/{id} |
Organization | Organizations::update() |
DELETE /admin/realms/{realm}/organizations/{id} |
ResponseInterface | Organizations::delete() |
GET /admin/realms/{realm}/organizations/{orgId}/members |
MemberCollection | Organizations::members() |
GET /admin/realms/{realm}/organizations/{orgId}/members/count |
int | Organizations::membersCount() |
GET /admin/realms/{realm}/organizations/{orgId}/members/{memberId} |
Member | Organizations::member() |
POST /admin/realms/{realm}/organizations/{orgId}/members |
ResponseInterface | Organizations::addMember() |
DELETE /admin/realms/{realm}/organizations/{orgId}/members/{memberId} |
ResponseInterface | Organizations::deleteMember() |
GET /admin/realms/{realm}/organizations/members/{memberId}/organizations |
OrganizationCollection | Organizations::memberOrganizations() |
GET /admin/realms/{realm}/organizations/{orgId}/members/{memberId}/organizations |
OrganizationCollection | Organizations::orgMemberOrganizations() |
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 |
|---|---|---|
GET /admin/realms |
RealmCollection | Realms::all() |
GET /admin/realms/{realm} |
Realm | Realms::get() |
POST /admin/realms |
Realm | Realms::import() |
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() |
GET /admin/realms/{realm}/users/{userId} |
UserRepresentation | Users::get() |
POST /admin/realms/{realm}/users |
UserRepresentation | Users::create() |
PUT /admin/realms/{realm}/users/{userId} |
UserRepresentation | Users::update() |
DELETE /admin/realms/{realm}/users/{userId} |
ResponseInterface | Users::delete() |
GET /admin/realms/{realm}/users |
UserCollection | Users::search() |
PUT /admin/realms/{realm}/users/{userId}/groups/{groupId} |
ResponseInterface | Users::joinGroup() |
DELETE /admin/realms/{realm}/users/{userId}/groups/{groupId} |
ResponseInterface | Users::leaveGroup() |
GET /admin/realms/{realm}/users/{userId}/groups |
GroupCollection | Users::retrieveGroups() |
GET /admin/realms/{realm}/users/{userId}/role-mappings/realm |
RoleCollection | Users::retrieveRealmRoles() |
GET /admin/realms/{realm}/users/{userId}/role-mappings/realm/available |
RoleCollection | Users::retrieveAvailableRealmRoles() |
POST /admin/realms/{realm}/users/{userId}/role-mappings/realm |
ResponseInterface | Users::addRealmRoles() |
DELETE /admin/realms/{realm}/users/{userId}/role-mappings/realm |
ResponseInterface | Users::removeRealmRoles() |
PUT /admin/realms/{realm}/users/{userId}/execute-actions-email |
ResponseInterface | Users::executeActionsEmail() |
POST /admin/realms/{realm}/users/{userId}/federated-identity/{provider} |
ResponseInterface | Users::addFederatedIdentity() |
DELETE /admin/realms/{realm}/users/{userId}/federated-identity/{provider} |
ResponseInterface | Users::removeFederatedIdentity() |
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 |
Role | Roles::create() |
DELETE /admin/realms/{realm}/roles/{roleName} |
ResponseInterface | Roles::delete() |
PUT /admin/realms/{realm}/roles/{roleName} |
Role | Roles::update() |
Root
| Endpoint | Response | API |
|---|---|---|
GET /admin/serverinfo |
ServerInfoRepresentation | 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
symfony/cache Version ^7.2
psr/simple-cache Version ^3.0