feat: better caching/fetching of JWKs from Auth0#244
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Improves Auth0 JWKS fetching to reduce request latency by extending JWKS caching and preventing concurrent refresh stampedes, with a new concurrency-focused test.
Changes:
- Increase JWKS cache TTL from 30 minutes to 6 hours.
- Add a module-level lock to ensure only one JWKS refresh occurs when the cache expires (and lock cache clear on retry).
- Add a test to validate concurrent refresh behavior.
Reviewed changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
auth/validator.py |
Extends JWKS cache TTL and adds locking around refresh/clear paths. |
tests/auth/test_auth_validator.py |
Adds a concurrency test to ensure only one JWKS refresh occurs when expired. |
uv.lock |
Updates editable package version metadata. |
Contributor
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
23579d3 to
cb1ce07
Compare
uwwint
requested changes
Mar 30, 2026
uwwint
approved these changes
Mar 30, 2026
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.
Description
Fetching of JWKs looks like a possible cause of slow responses in the backend API. Make some improvements to minimize the impacts of JWK lookups on response time.
Changes
time.sleep()with explicitEvent-based synchronization and increasing thread timeoutsChecklist
How to Test Manually (if necessary)
Run
uv run pytest⌨️ Start Copilot coding agent tasks without leaving your editor — available in VS Code, Visual Studio, JetBrains IDEs and Eclipse.