Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
Axel Messinese authored and Axel Messinese committed Nov 7, 2024
1 parent 8875f13 commit c72bc8c
Showing 1 changed file with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
*/
package org.keycloak.services.resources.admin;

import jakarta.ws.rs.*;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.extensions.Extension;
import org.eclipse.microprofile.openapi.annotations.parameters.Parameter;
import org.eclipse.microprofile.openapi.annotations.tags.Tag;
import org.jboss.logging.Logger;
import org.jboss.resteasy.annotations.cache.NoCache;
import jakarta.ws.rs.NotFoundException;
import org.keycloak.events.admin.OperationType;
import org.keycloak.events.admin.ResourceType;
import org.keycloak.models.ClientModel;
Expand All @@ -39,15 +39,6 @@
import org.keycloak.services.resources.admin.permissions.AdminPermissionManagement;
import org.keycloak.services.resources.admin.permissions.AdminPermissions;

import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.DELETE;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import java.util.List;
Expand Down Expand Up @@ -303,6 +294,29 @@ public static ManagementPermissionReference toMgmtRef(RoleModel role, AdminPermi
return ref;
}

/**
* Get parents of the roles, thoses which have the given role as composite
*
* @param id Role id
* @param briefRepresentation if false, return a full representation of the roles with their attributes
* @return parents of the roles
*/
@Path("{role-id}/parents")
@GET
@NoCache
@Produces(MediaType.APPLICATION_JSON)
public Set<RoleRepresentation> getParentsRoles(final @PathParam("role-id") String id,
final @QueryParam("briefRepresentation") @DefaultValue("true") boolean briefRepresentation) {
RoleModel role = getRoleModel(id);
auth.roles().requireManage(role);

if (role == null) {
throw new NotFoundException("Could not find role");
}

return getParentsRoles(role, briefRepresentation);
}

/**
* Return object stating whether role Authorization permissions have been initialized or not and a reference
*
Expand Down

0 comments on commit c72bc8c

Please sign in to comment.