diff --git a/README.md b/README.md index c58b329..fe04c38 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,10 @@ For this it will provide API endpoints for every configured attribute-group. The configuration of the provider is possible via an admin page. Every endpoint responds with a list of all attribute values, that: - - is in the attribute group matching `attribute-group` - - matches an optional RegEx Pattern `attribute-regex` - - belongs to a user with a role matching `match-role` - - is non-empty +- are in the attribute group matching `attribute-group` +- match an optional RegEx Pattern `attribute-regex` +- belong to a user with a role matching `match-role` +- are non-empty Multivalue attributes are flattened in the response. diff --git a/attribute-endpoints-provider/src/main/java/de/ccc/hamburg/keycloak/attribute_endpoints/AdminUiPage.java b/attribute-endpoints-provider/src/main/java/de/ccc/hamburg/keycloak/attribute_endpoints/AdminUiPage.java index 6267bb5..cc2095f 100644 --- a/attribute-endpoints-provider/src/main/java/de/ccc/hamburg/keycloak/attribute_endpoints/AdminUiPage.java +++ b/attribute-endpoints-provider/src/main/java/de/ccc/hamburg/keycloak/attribute_endpoints/AdminUiPage.java @@ -24,7 +24,7 @@ import com.google.auto.service.AutoService; */ @AutoService(UiPageProviderFactory.class) public class AdminUiPage implements UiPageProvider, UiPageProviderFactory { - public static final String PROVIDER_ID = "🪪 Attribute Endpoints 🚀"; + public static final String PROVIDER_ID = "Attribute Endpoints"; @Override public void init(Config.Scope config) { diff --git a/attribute-endpoints-provider/src/main/java/de/ccc/hamburg/keycloak/attribute_endpoints/AttributeEndpointsResourceProvider.java b/attribute-endpoints-provider/src/main/java/de/ccc/hamburg/keycloak/attribute_endpoints/AttributeEndpointsResourceProvider.java index 953110c..8c17ec3 100644 --- a/attribute-endpoints-provider/src/main/java/de/ccc/hamburg/keycloak/attribute_endpoints/AttributeEndpointsResourceProvider.java +++ b/attribute-endpoints-provider/src/main/java/de/ccc/hamburg/keycloak/attribute_endpoints/AttributeEndpointsResourceProvider.java @@ -53,7 +53,7 @@ public class AttributeEndpointsResourceProvider implements RealmResourceProvider @GET @Path("export/{slug}") @Produces(MediaType.APPLICATION_JSON) - public Response exportKeys(@PathParam("slug") String slug) { + public Response exportAttributeValues(@PathParam("slug") String slug) { KeycloakContext context = session.getContext(); RealmModel realm = context.getRealm(); @@ -62,11 +62,16 @@ public class AttributeEndpointsResourceProvider implements RealmResourceProvider .filter(c -> c.getConfig().getFirst("slug").equals(slug)) .toList(); + Auth auth = AttributeEndpointsResourceProvider.getAuth(session); + if (componentList.isEmpty()) { throw new NotFoundException("Endpoint not found."); } - Auth auth = AttributeEndpointsResourceProvider.getAuth(session); + if (componentList.size() > 1) { + throw new NotFoundException( + "Endpoint Configuration Error - Multiple configurations exist for this endpoint."); + } ComponentModel component = componentList.get(0); @@ -106,11 +111,6 @@ public class AttributeEndpointsResourceProvider implements RealmResourceProvider throw new ForbiddenException("User does not have required auth role."); } - if (componentList.size() > 1) { - throw new NotFoundException( - "Endpoint Configuration Error - Multiple configurations exist for this endpoint."); - } - List attributeNames = upconfig.getAttributes() .stream() .filter(a -> a.getGroup() != null && a.getGroup().equals(configAttributeGroup))