-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Headers for (namespaced) claims are truncated #183
Comments
thanks @betagan that's an interesting corner case Thanks much for the PR #184 Can I suggest expanding the replacement beyond colon to all non alphanum characters? And could you please update the documentation in the relevant portion of the configuration file to explain the transposition? FYI I looked at the JWT RFC but it really doesn't have much guidance on naming conventions
Cheers! |
actually, after re-reading your note above let me take that back... If '_' works this is really specific to ':' is that correct? Did you test any other claim name aberrations by any chance? |
I've given it more thought and we should replace all characters that are not allowed as part of a HTTP header field name. The RFC 822 states in 3.1.2.
I'll take the time to update the PR later. |
@betagan friendly nudge, do you have any time in these busy days to improve this PR? No real rush but I figured I'd ask since I was poking my nose at the Vouch issues and PRs. |
@betagan any chance of moving this forward? Your help is very much appreciated. If not, just let me know and I'll mark it as "help_wanted" |
Piling onto this, Auth0 uses URLs for their claim namespace: https://auth0.com/docs/tokens/guides/create-namespaced-custom-claims So a custom claim would be of the form |
okie dokey @betagan thanks for the contribution, I've refactored to something more robust in These become dashes since they are not allowed as per the RFC: "(),/:;<=>?@[]{}" nginx doesn't like underscores so they become dashes too And we apply golang's http.CanonicalHeaderKey() And as per @redterror any prepended There is a I won't be surprised if a few folks out there will need to adjust their Nginx configs to accommodate these rules, however I expect a broader array of claims to be able to be accommodated such as #221 |
@bnfinet any chance we could add In my example, my claim is being returned as
PS - The debug log lines are 💯. |
oh that's a good catch. Just pushed wrt "Valid names are composed of English letters, digits, hyphens" makes me think this should be even more restrictive. |
TLDR
given a claim
custom:roles
with valueadministrator
expected result: a header
X-Vouch-IdP-Claims-custom:roles
with valueadministrator
actual result: a header
X-Vouch-IdP-Claims-custom
with valueroles: administrator
Context
when we add custom claims in the vouch-proxy config.yml like
vouch-proxy will pass these on to the application via headers. This works for claims like the given_name in the above example, but will produce unexpected results for claims containing a colon like in the example above. AWS Cognito uses this kind of namespace to identify attributes that are not part of their standard attribute set but rather added by the customer. Other IdP might have a similar namespace feature using colons.
In the above example, vouch-proxy will create a header named X-Vouch-IdP-Claims-custom and it will have the value
roles: actual_content
as the first colon is interpreted as the separator between header and value.I realize the expected result is impossible as headers can't have colons, but I think vouch-proxy should perform some sort of substitution to achieve something similar. In Any case, rewriting part of the key into the value seems to be unintended.
I will open a PR with our current workaround, replacing colon with dash. It can certainly be reworked into a more complete solution though.
The text was updated successfully, but these errors were encountered: