Skip to content

Conversation

@grounded042
Copy link
Contributor

Many times JWTs will be signed with a JWKS. When working with JWKS it is beneficial to cache the keys used to check token in order to decrease request round-trip and keep from potentially hitting identity provider rate limits. This PR adds a JWKS provider to the josev2 validator as well as a caching JWKS provider.

@grounded042 grounded042 requested a review from a team as a code owner July 9, 2021 20:12
Signed-off-by: Jon Carl <[email protected]>
Signed-off-by: Jon Carl <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Jul 9, 2021

Codecov Report

Merging #97 (c3d388a) into v2 (66a443b) will decrease coverage by 6.86%.
The diff coverage is 65.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##               v2      #97      +/-   ##
==========================================
- Coverage   92.42%   85.55%   -6.87%     
==========================================
  Files           3        3              
  Lines         132      180      +48     
==========================================
+ Hits          122      154      +32     
- Misses          9       21      +12     
- Partials        1        5       +4     
Impacted Files Coverage Δ
validate/josev2/josev2.go 74.69% <65.11%> (-11.02%) ⬇️
jwtmiddleware.go 92.95% <0.00%> (-0.80%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 66a443b...c3d388a. Read the comment docs.

Signed-off-by: Jon Carl <[email protected]>
validator, err := josev2.New(
// p.KeyFunc, // uncomment this to use the caching key provider
keyFunc,
jose.HS256,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using JWKS, this will in most cases be RS256 instead of HS256?

@wimdec
Copy link

wimdec commented Jul 12, 2021

@grounded042
Copy link
Contributor Author

@wimdec thanks for the review! I think I'll break out a second example for JWKS specifically.

@grounded042 grounded042 mentioned this pull request Jul 16, 2021
21 tasks
@grounded042 grounded042 merged commit 924c5c9 into v2 Jul 16, 2021
@grounded042 grounded042 deleted the josev2_jwks branch July 16, 2021 19:44
d10i pushed a commit to Hikely/go-jwt-middleware that referenced this pull request Nov 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants