|
|
@ -1057,6 +1057,53 @@ class KeycloakAdmin: |
|
|
|
data_raw = self.raw_get(URL_ADMIN_GET_GROUPS_REALM_ROLES.format(**params_path)) |
|
|
|
return raise_error_from_response(data_raw, KeycloakGetError) |
|
|
|
|
|
|
|
def assign_group_client_roles(self, group_id, client_id, roles): |
|
|
|
""" |
|
|
|
Assign client roles to a group |
|
|
|
|
|
|
|
:param group_id: id of group |
|
|
|
:param client_id: id of client (not client-id) |
|
|
|
:param roles: roles list or role (use GroupRoleRepresentation) |
|
|
|
:return Keycloak server response |
|
|
|
""" |
|
|
|
|
|
|
|
payload = roles if isinstance(roles, list) else [roles] |
|
|
|
params_path = {"realm-name": self.realm_name, "id": group_id, "client-id": client_id} |
|
|
|
data_raw = self.raw_post(URL_ADMIN_GROUPS_CLIENT_ROLES.format(**params_path), |
|
|
|
data=json.dumps(payload)) |
|
|
|
return raise_error_from_response(data_raw, KeycloakGetError, expected_code=204) |
|
|
|
|
|
|
|
def delete_group_client_roles(self, group_id, client_id, roles): |
|
|
|
""" |
|
|
|
Delete client roles of a group |
|
|
|
|
|
|
|
:param group_id: id of group |
|
|
|
:param client_id: id of client (not client-id) |
|
|
|
:param roles: roles list or role (use GroupRoleRepresentation) |
|
|
|
:return Keycloak server response |
|
|
|
""" |
|
|
|
|
|
|
|
payload = roles if isinstance(roles, list) else [roles] |
|
|
|
params_path = {"realm-name": self.realm_name, "id": group_id, "client-id": client_id} |
|
|
|
data_raw = self.raw_get(URL_ADMIN_GROUPS_CLIENT_ROLES.format(**params_path)) |
|
|
|
return raise_error_from_response(data_raw, KeycloakGetError) |
|
|
|
|
|
|
|
def get_group_client_roles(self, group_id, client_id, roles): |
|
|
|
""" |
|
|
|
Get client roles of a group |
|
|
|
|
|
|
|
:param group_id: id of group |
|
|
|
:param client_id: id of client (not client-id) |
|
|
|
:param roles: roles list or role (use GroupRoleRepresentation) |
|
|
|
:return Keycloak server response (array RoleRepresentation) |
|
|
|
""" |
|
|
|
|
|
|
|
payload = roles if isinstance(roles, list) else [roles] |
|
|
|
params_path = {"realm-name": self.realm_name, "id": group_id, "client-id": client_id} |
|
|
|
data_raw = self.raw_delete(URL_ADMIN_GROUPS_CLIENT_ROLES.format(**params_path), |
|
|
|
data=json.dumps(payload)) |
|
|
|
return raise_error_from_response(data_raw, KeycloakGetError, expected_code=204) |
|
|
|
|
|
|
|
def get_client_roles_of_user(self, user_id, client_id): |
|
|
|
""" |
|
|
|
Get all client roles for a user. |
|
|
|