Repository navigation
Support string-list JWT claims such as aud in meta_claims - #114
Merged
Merged
Conversation
Owner
|
Thank you @steffenbusch for the contribution! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fix
meta_claimspopulation for JWT claims that are decoded as[]string, most notably the registeredaudclaim.caddy-jwt currently stringifies array-like metadata only when the claim value is
[]interface{}. This works for many private claims, but it does not work for registered claims such asaud, because the underlying JWT library decodes them as[]string.As a result, configurations such as:
successfully validate the audience, but
{http.auth.user.aud}remains empty.Root Cause
The JWT library treats
audas a standard claim and decodes it into a dedicated string-list type, which is exposed to caddy-jwt as[]string.caddy-jwt currently supports:
stringbooljson.Numbertime.Time[]interface{}fmt.Stringerbut not
[]string.This causes
meta_claims "aud"to resolve to an empty string instead of a comma-separated value.Changes
[]stringsupport tostringify()meta_claims "aud"is populated correctlystringify()unit test to cover[]stringExample
Given a token containing:
{ "aud": ["aud1", "aud2", "aud3"] }and this config:
the placeholder
{http.auth.user.aud}now resolves toaud1,aud2,aud3.Backward Compatibility
This is backward-compatible. It only adds support for an additional value type that was previously dropped during stringification.