Compare commits

..

4 commits

Author SHA1 Message Date
e4b4497b30
introduce path parameter in export endpoint for specifying group id
Co-authored-by: kritzl <kritzl@kritzl.dev>
2025-10-31 19:54:35 +01:00
8e9674cf5c
update dev setup in compose.yaml
Co-authored-by: kritzl <kritzl@kritzl.dev>
2025-10-31 19:54:33 +01:00
9a4dbfeb16
remove test route
Co-authored-by: kritzl <kritzl@kritzl.dev>
2025-10-31 19:54:30 +01:00
c518d4a514
rename package
Co-authored-by: kritzl <kritzl@kritzl.dev>
2025-10-31 19:54:28 +01:00
4 changed files with 6 additions and 14 deletions

View file

@ -10,4 +10,4 @@ services:
ports:
- "8080:8080"
volumes:
- ./local-dev/providers/:/opt/keycloak/providers/
- ./ssh-key-provider/target/ssh-key-provider-1.0-SNAPSHOT.jar:/opt/keycloak/providers/ssh-key-provider.jar

View file

View file

@ -6,6 +6,7 @@ import java.util.stream.Stream;
import org.jboss.logging.Logger;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.MediaType;
@ -35,19 +36,9 @@ public class SSHKeyResourceProvider implements RealmResourceProvider {
}
@GET
@Path("hello")
@Path("export/{group_id}")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Public hello endpoint", description = "This endpoint returns hello and the name of the requested realm.")
@APIResponse(responseCode = "200", description = "", content = {
@Content(schema = @Schema(implementation = Response.class, type = SchemaType.OBJECT)) })
public Response helloAnonymous() {
return Response.ok(Map.of("hello", session.getContext().getRealm().getName())).build();
}
@GET
@Path("hello-auth")
@Produces(MediaType.APPLICATION_JSON)
public Response helloAuthenticated() {
public Response exportKeys(@PathParam("group_id") String groupId) {
UserProvider userProvider = session.users();
try {
@ -55,7 +46,8 @@ public class SSHKeyResourceProvider implements RealmResourceProvider {
authResult -> authResult.getToken().getIssuedFor().equals("admin-cli"));
RealmModel realm = session.getContext().getRealm();
GroupModel group = realm.getGroupById("fbf5f78b-d2be-49dd-b04f-11a5e8ee583f");
// TODO: add allowlist check
GroupModel group = realm.getGroupById(groupId);
LOG.info(String.format("Getting Users from Group \"%s\" with ID %s", group.getName(), group.getId()));