Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#29266 Improve documentation on ClientRolemappingsRessource #29344

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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