google / jwt_verify_lib

Provide c++ library to verify JWT tokens
Apache License 2.0
41 stars 43 forks source link

Allow use of URL-namespaced claims #94

Open willthames opened 1 year ago

willthames commented 1 year ago

Private namespaced claims are recommended to be prefixed with URLs, but having dots in domain names means that working out nested key structure by splitting on dots doesn't work.

Instead we assume that if a claim starts with http:// or https:// then everything up to the third slash is part of the top-level key

So https://example.com/nested.claims.key gets treated as https://example.com/nested -> claims -> key

google-cla[bot] commented 1 year ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-oss-prow[bot] commented 1 year ago

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: willthames Once this PR has been reviewed and has the lgtm label, please assign nareddyt for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files: - **[OWNERS](https://github.com/google/jwt_verify_lib/blob/master/OWNERS)** Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
google-oss-prow[bot] commented 1 year ago

Hi @willthames. Thanks for your PR.

I'm waiting for a google member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.
willthames commented 1 year ago

I'll mark this as draft while I work on getting the CLA sorted.

nareddyt commented 1 year ago

/ok-to-test

willthames commented 1 year ago

Private namespaced claims are recommended to be prefixed with URLs

Can you link to a specification that mentions this?

https://auth0.com/docs/secure/tokens/json-web-tokens/create-custom-claims#namespaced-guidelines

See also https://github.com/quarkusio/quarkus/issues/26185 for a similar issue in another library

It might only be auth0 who recommend this, but auth0 are a major advocate of JWT (they seem to be behind jwt.io for example)

jgorinsky commented 1 year ago

I ran into this issue while trying to extract namespaced JWT claims into headers with envoy.

The JWT RFC (https://datatracker.ietf.org/doc/html/rfc7519#section-4.2) mentions using a domain name as a "Collision-Resistant Name" for claims and includes an example elsewhere using a domain namespaced claim:

{
  "iss":"joe",
  "exp":1300819380,
  "http://example.com/is_root":true
}