[WIP] Improvements to handle custom and/or nested claims and/or dynamic client_id
#4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Here are some modifications to improve the options when using Keycloak
e.g.
rolename1;rolename2;rolename3
will still look for these values inuser-realm-role
e.g.
wp-roles.rolename1;wp-roles.rolename2;wp-roles.rolename3
will look for these values inwp-roles
instead ofuser-realm-role
e.g.
wp-roles.roles.aaa.rolename1;wp-roles.roles.a.aarolename2;wp-roles.roles.aaa.rolename3
will look for these values inwp-roles: { roles : { aaa: [ -> here <-] } }
instead ofuser-realm-role
e.g.
resource_access.$client_id.roles.editor
will look for this value inresource_access: { wordpress-abc : { roles: [ -> here <-] } }
instead ofuser-realm-role
, if yourclient_id
iswordpress-abc
When you go in Keycloak Admin Console, to
Clients > Client details > Roles
and add roles, these roles are specific to that client. Now you can reference them in Wordpress, using that (mu-)plugin ! 🥳These code modifications has been tested with all use-cases described here. However, the code is a bit messy and could be improved/formatted/optimized 😅
Don't hesitate to give your thoughs ! I hope it will be flexible enough to fit the needs of everyone here 🙌