renaming and sort some code
This commit is contained in:
parent
88ffb9b9f4
commit
ffa6c92c65
3 changed files with 12 additions and 12 deletions
|
|
@ -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.
|
The configuration of the provider is possible via an admin page.
|
||||||
|
|
||||||
Every endpoint responds with a list of all attribute values, that:
|
Every endpoint responds with a list of all attribute values, that:
|
||||||
- is in the attribute group matching `attribute-group`
|
- are in the attribute group matching `attribute-group`
|
||||||
- matches an optional RegEx Pattern `attribute-regex`
|
- match an optional RegEx Pattern `attribute-regex`
|
||||||
- belongs to a user with a role matching `match-role`
|
- belong to a user with a role matching `match-role`
|
||||||
- is non-empty
|
- are non-empty
|
||||||
|
|
||||||
Multivalue attributes are flattened in the response.
|
Multivalue attributes are flattened in the response.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import com.google.auto.service.AutoService;
|
||||||
*/
|
*/
|
||||||
@AutoService(UiPageProviderFactory.class)
|
@AutoService(UiPageProviderFactory.class)
|
||||||
public class AdminUiPage implements UiPageProvider, UiPageProviderFactory<ComponentModel> {
|
public class AdminUiPage implements UiPageProvider, UiPageProviderFactory<ComponentModel> {
|
||||||
public static final String PROVIDER_ID = "🪪 Attribute Endpoints 🚀";
|
public static final String PROVIDER_ID = "Attribute Endpoints";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(Config.Scope config) {
|
public void init(Config.Scope config) {
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ public class AttributeEndpointsResourceProvider implements RealmResourceProvider
|
||||||
@GET
|
@GET
|
||||||
@Path("export/{slug}")
|
@Path("export/{slug}")
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public Response exportKeys(@PathParam("slug") String slug) {
|
public Response exportAttributeValues(@PathParam("slug") String slug) {
|
||||||
KeycloakContext context = session.getContext();
|
KeycloakContext context = session.getContext();
|
||||||
RealmModel realm = context.getRealm();
|
RealmModel realm = context.getRealm();
|
||||||
|
|
||||||
|
|
@ -62,11 +62,16 @@ public class AttributeEndpointsResourceProvider implements RealmResourceProvider
|
||||||
.filter(c -> c.getConfig().getFirst("slug").equals(slug))
|
.filter(c -> c.getConfig().getFirst("slug").equals(slug))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
|
Auth auth = AttributeEndpointsResourceProvider.getAuth(session);
|
||||||
|
|
||||||
if (componentList.isEmpty()) {
|
if (componentList.isEmpty()) {
|
||||||
throw new NotFoundException("Endpoint not found.");
|
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);
|
ComponentModel component = componentList.get(0);
|
||||||
|
|
||||||
|
|
@ -106,11 +111,6 @@ public class AttributeEndpointsResourceProvider implements RealmResourceProvider
|
||||||
throw new ForbiddenException("User does not have required auth role.");
|
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<String> attributeNames = upconfig.getAttributes()
|
List<String> attributeNames = upconfig.getAttributes()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(a -> a.getGroup() != null && a.getGroup().equals(configAttributeGroup))
|
.filter(a -> a.getGroup() != null && a.getGroup().equals(configAttributeGroup))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue