Skip to content

Conversation

aemard
Copy link

@aemard aemard commented May 19, 2025

Description

This PR adds Cache-Control headers to JWKS endpoint requests to ensure fresh keys are always fetched from the authorization server instead of potentially stale cached versions from HTTP-level caches (e.g., browser cache, proxies, CDNs), while preserving application-level caching in localStorage.

What Problem Does This Solve?

When keys are rotated at the authorization server, HTTP-level caching can cause the SDK to continue using stale keys, which may lead to token validation failures.

Changes Made

  • Added Cache-Control: no-cache, no-store, max-age=0 headers to JWKS endpoint requests
  • Ensured application-level caching in localStorage remains unaffected
  • Updated corresponding tests to match the new headers

Testing Done

  • Updated unit tests to verify headers are properly sent
  • Manually verified that keys are always fetched fresh from the server

Security Impact

Positive: Reduces the window of vulnerability when keys are rotated by ensuring fresh keys are always used for token validation.

Prevents stale key issues by adding Cache-Control headers to force fresh
JWKS key fetches from the authorization server while preserving application-level
caching in localStorage.
@jaredperreault-okta
Copy link
Contributor

@aemard Can please send a signed CLA to [email protected]

@aemard
Copy link
Author

aemard commented Jun 12, 2025

@jaredperreault-okta CLA signed and sent to [email protected]

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.

2 participants