From b62f0182d5996d7f971678e6ae84fd2f4e753382 Mon Sep 17 00:00:00 2001 From: Vincent Creuza Date: Wed, 18 Nov 2020 15:00:11 +0100 Subject: [PATCH] Added user assignment to groups and updated doc --- README.md | 4 +-- src/Admin/KeycloakClient.php | 2 ++ src/Admin/Resources/keycloak-1_0.php | 52 ++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dd63ca0..8ca9d6b 100644 --- a/README.md +++ b/README.md @@ -477,8 +477,8 @@ Note: Ids are sent as clientScopeId or clientId and mapperId everything else is | Remove a social login provider from user | | ❌ | | GET /{realm}/users/{id}/groups | getUserGroups | ✔️ | | GET /{realm}/users/{id}/groups/count | getUserGroupsCount | ✔️ | -| PUT /{realm}/users/{id}/groups/{groupId} | | ❌ | -| DELETE /{realm}/users/{id}/groups/{groupId} | | ❌ | +| PUT /{realm}/users/{id}/groups/{groupId} | addUserToGroup | ✔️ | +| DELETE /{realm}/users/{id}/groups/{groupId} | deleteUserFromGroup | ✔️ | | Impersonate the user | | ❌ | | Remove all user sessions associated with the user Also send notification to all clients that have an admin URL to invalidate the sessions for the particular user. | | ❌ | | Get offline sessions associated with the user and client | | ❌ | diff --git a/src/Admin/KeycloakClient.php b/src/Admin/KeycloakClient.php index f6d4a0c..62bf99a 100644 --- a/src/Admin/KeycloakClient.php +++ b/src/Admin/KeycloakClient.php @@ -252,6 +252,8 @@ * @method array getUserGroupsCount(array $args = array()) { @command Keycloak getUserGroupsCount } * @method array updateUser(array $args = array()) { @command Keycloak updateUser } * @method array deleteUser(array $args = array()) { @command Keycloak deleteUser } + * @method array addUserToGroup(array $args = array()) { @command Keycloak addUserToGroup } + * @method array deleteUserFromGroup(array $args = array()) { @command Keycloak deleteUserFromGroup } * */ diff --git a/src/Admin/Resources/keycloak-1_0.php b/src/Admin/Resources/keycloak-1_0.php index 3d6320b..f394c3e 100644 --- a/src/Admin/Resources/keycloak-1_0.php +++ b/src/Admin/Resources/keycloak-1_0.php @@ -4963,5 +4963,57 @@ ), ), + 'addUserToGroup' => array( + 'uri' => 'auth/admin/realms/{realm}/users/{id}/groups/{groupId}', + 'description' => 'Assign a specific user to a specific group', + 'httpMethod' => 'PUT', + 'parameters' => array( + 'realm' => array( + 'location' => 'uri', + 'description' => 'The Realm name', + 'type' => 'string', + 'required' => true, + ), + 'id' => array( + 'location' => 'uri', + 'description' => 'User id', + 'type' => 'string', + 'required' => true, + ), + 'groupId' => array( + 'location' => 'uri', + 'description' => 'Group id', + 'type' => 'string', + 'required' => true, + ), + ), + ), + + 'deleteUserFromGroup' => array( + 'uri' => 'auth/admin/realms/{realm}/users/{id}/groups/{groupId}', + 'description' => 'Remove a specific user from a specific group', + 'httpMethod' => 'DELETE', + 'parameters' => array( + 'realm' => array( + 'location' => 'uri', + 'description' => 'The Realm name', + 'type' => 'string', + 'required' => true, + ), + 'id' => array( + 'location' => 'uri', + 'description' => 'User id', + 'type' => 'string', + 'required' => true, + ), + 'groupId' => array( + 'location' => 'uri', + 'description' => 'Group id', + 'type' => 'string', + 'required' => true, + ), + ), + ), + ) //End of Operations Array );//End of return array