feat: allow custom extra fields for KeycloakToken
#9
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.
The should fix #7 and furthurmore provides ability to define custom jwt scopes/fields.
The previous version hard coded first_name, last_name, email and etc into
KeycloakToken
. But these tokens can actually be turned off, especially when configured with external identity services.This PR add a generic parameter named
Extra
and passes it all the way through into KeycloakToken. Also,ProfileAndEmail
is provided as the defaultExtra
generic type, to meet the needs of most keycloak user that sticks with default usage (username/email/password authentication and never border to turned off profile or email scope).I bump the version in Cargo.toml to 0.5.0, since this commit introduces some breaking API changes. There is no more
token.full_name
buttoken.extra.profile.preferred_username
whenExtra
is set toProfileAndEmail
, which is the default generic type.Here is an example to define and use custom jwt extra scopes: