Configure Extension with UiPageProvider #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "addUiPageProvider"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Tested by following the README and using the compose file and it works great. Generally looks good, just a few small things here and there.
@ -0,0 +8,4 @@- 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-emptyShould use plural, like:
@ -0,0 +24,4 @@*/@AutoService(UiPageProviderFactory.class)public class AdminUiPage implements UiPageProvider, UiPageProviderFactory<ComponentModel> {public static final String PROVIDER_ID = "🪪 Attribute Endpoints 🚀";I think getting rid of the emojis, while they are fun, might be a good idea.
@ -0,0 +53,4 @@@GET@Path("export/{slug}")@Produces(MediaType.APPLICATION_JSON)public Response exportKeys(@PathParam("slug") String slug) {I guess this should be called something like
exportAttributeValuesnow that this is not just about SSH Keys anymore.@ -0,0 +106,4 @@throw new ForbiddenException("User does not have required auth role.");}if (componentList.size() > 1) {Moving this before line 71, where we get the component to work with might make a bit more sense flow-wise.
Oh, and we have both a
test.jsonand arealm-export.json. Do we want to keep them both, one or none?Reading through the code, I noticed that we are duplicating the validation logic for the
AdminUiPageand theAttributeEndpointsResourceProvider. I think this is fine, as it's just refactoring and they do both cater to slightly different use-cases, so a refactor needs some thought, but we might want to look into abstracting that into one place in the future.@ -0,0 +55,4 @@Pattern slugPattern = Pattern.compile("^[a-zA-Z0-9_-]*$");String configAttributeSlug = model.getConfig().getFirst("slug");if (!slugPattern.matcher(configAttributeSlug).matches()) {Currently this gives us an ugly exception in the Keycloak logs for an empty slug, as
configAttributeSlugis thennull. Not critical as it still just errors, but we should probably check, ifconfigAttributeSlugisnull. I guess then adding a null check to all the otherconfig$things is probably a good idea as well.@june wrote in #1 (comment):
I don't think we need them at all ^^
@june can you test if the last commit works as it is intended? My setup is currently broken
Just a one more small fix needed, but everything else looks great now!
Will just test the null checks now.
@ -0,0 +53,4 @@- After creating:- give it the role `myattribute-export`- set a password in the users settings `Creadentials > Set password`. For Example `"password"`8. Under `🪪 Attribute Endpoints 🚀 > Create item`, add a new endpoint to the providerThis needs to be changed to reflect the new emoji-less version.
@kritzl wrote in #1 (comment):
It still failed in an ugly way for the
configAttributeSlugas the further validation was still performed, so pushed a commit to only validate non-null config strings further.If you think it looks good as well, then let's merge. @kritzl