Skip to content

Commit

Permalink
Improve documentation on ClientRolemappingsRessource
Browse files Browse the repository at this point in the history
Closes #29266

Signed-off-by: Sebastian Prehn <sebastian.prehn@ero.eu>
  • Loading branch information
sprehn-ero committed May 13, 2024
1 parent d1549a0 commit 53b25ce
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public ClientRoleMappingsResource(UriInfo uriInfo, KeycloakSession session, Real
@Produces(MediaType.APPLICATION_JSON)
@NoCache
@Tag(name = KeycloakOpenAPI.Admin.Tags.CLIENT_ROLE_MAPPINGS)
@Operation( summary = "Get client-level role mappings for the user, and the app")
@Operation( summary = "Get client-level role mappings for the user or group, and the app")
public Stream<RoleRepresentation> getClientRoleMappings() {
viewPermission.require();

Expand Down Expand Up @@ -134,7 +134,7 @@ public Stream<RoleRepresentation> getCompositeClientRoleMappings(@Parameter(desc
}

/**
* Get available client-level roles that can be mapped to the user
* Get available client-level roles that can be mapped to the user or group
*
* @return
*/
Expand All @@ -143,7 +143,7 @@ public Stream<RoleRepresentation> getCompositeClientRoleMappings(@Parameter(desc
@Produces(MediaType.APPLICATION_JSON)
@NoCache
@Tag(name = KeycloakOpenAPI.Admin.Tags.CLIENT_ROLE_MAPPINGS)
@Operation( summary = "Get available client-level roles that can be mapped to the user")
@Operation( summary = "Get available client-level roles that can be mapped to the user or group")
public Stream<RoleRepresentation> getAvailableClientRoleMappings() {
viewPermission.require();

Expand All @@ -154,14 +154,14 @@ public Stream<RoleRepresentation> getAvailableClientRoleMappings() {
}

/**
* Add client-level roles to the user role mapping
* Add client-level roles to the user or group role mapping
*
* @param roles
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Tag(name = KeycloakOpenAPI.Admin.Tags.CLIENT_ROLE_MAPPINGS)
@Operation( summary = "Add client-level roles to the user role mapping")
@Operation( summary = "Add client-level roles to the user or group role mapping")
@APIResponse(responseCode = "204", description = "No Content")
public void addClientRoleMapping(List<RoleRepresentation> roles) {
managePermission.require();
Expand All @@ -180,22 +180,22 @@ public void addClientRoleMapping(List<RoleRepresentation> roles) {
throw ErrorResponse.error(e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR);
} catch (ModelException | ReadOnlyException me) {
logger.warn(me.getMessage(), me);
throw new ErrorResponseException("invalid_request", "Could not add user role mappings!", Response.Status.BAD_REQUEST);
throw new ErrorResponseException("invalid_request", "Could not add user role or group mappings!", Response.Status.BAD_REQUEST);
}

adminEvent.operation(OperationType.CREATE).resourcePath(uriInfo).representation(roles).success();

}

/**
* Delete client-level roles from user role mapping
* Delete client-level roles from user or group role mapping
*
* @param roles
*/
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
@Tag(name = KeycloakOpenAPI.Admin.Tags.CLIENT_ROLE_MAPPINGS)
@Operation( summary = "Delete client-level roles from user role mapping")
@Operation( summary = "Delete client-level roles from user or group role mapping")
public void deleteClientRoleMapping(List<RoleRepresentation> roles) {
managePermission.require();

Expand All @@ -222,7 +222,7 @@ public void deleteClientRoleMapping(List<RoleRepresentation> roles) {
throw ErrorResponse.error(e.getMessage(), Response.Status.INTERNAL_SERVER_ERROR);
} catch (ModelException | ReadOnlyException me) {
logger.warn(me.getMessage(), me);
throw new ErrorResponseException("invalid_request", "Could not remove user role mappings!", Response.Status.BAD_REQUEST);
throw new ErrorResponseException("invalid_request", "Could not remove user or group role mappings!", Response.Status.BAD_REQUEST);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ private boolean canMapRole(RoleModel roleModel) {
return auth.roles().canMapRole(roleModel);
}

@Path("clients/{client}")
public ClientRoleMappingsResource getUserClientRoleMappingsResource(@PathParam("client") String client) {
@Path("clients/{client-id}")
public ClientRoleMappingsResource getUserClientRoleMappingsResource(@PathParam("client-id") @Parameter(description = "client id (not clientId!)") String client) {
ClientModel clientModel = realm.getClientById(client);
if (clientModel == null) {
throw new NotFoundException("Client not found");
Expand Down

0 comments on commit 53b25ce

Please sign in to comment.