marcospereirampj / python-keycloak

MIT License
722 stars 301 forks source link

feat: allows retrieval of realm and client level roles for a user #512

Closed comemaryvallee closed 6 months ago

comemaryvallee commented 9 months ago

Adding method get_all_roles_of_user to KeycloakAdmin. Adding URL_ADMIN_USER_ALL_ROLES to url_patterns

This PR adds the functionality of retrieving roles from realm and client levels for a user. Within my team, we need to retrieve all of a user's clients roles. Currently, the only way to do this is by looping through all clients in a realm and using the KeycloakAdmin.get_client_roles_of_user function. This method requires a lot of calls and is very time consuming in the case of a large number of clients. Using the GET /admin/realms/{realm}/users/{id}/role-mappings endpoint of the Keycloak REST API would meet our need with only one request.