fix: add timeouts for JWKS HTTPS requests and share key registry across Traefik routes#87
Open
groot314 wants to merge 2 commits into
Open
fix: add timeouts for JWKS HTTPS requests and share key registry across Traefik routes#87groot314 wants to merge 2 commits into
groot314 wants to merge 2 commits into
Conversation
added 2 commits
July 14, 2026 19:22
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.
Fixes #86
Problem
As described in #86,
ForceRefreshKeyscan block requests forever: the request goroutine waits on an unbounded channel handshake with the refresh goroutine, and JWKS fetches use a defaulthttp.Clientwith no timeout, so a hanging JWKS endpoint stalls requests indefinitely.There is a second related failure mode: Traefik constructs a separate plugin instance per router chain referencing the middleware, and rebuilds them all on every dynamic configuration reload. The current code cancels "the previous" background refresh goroutine by plugin name, which kills the refresher of a sibling instance that is still serving — freezing its cached JWKS keys.
Changes
JwksFetchTimeoutSecsconfig option bounds each JWKS request, and (withForceRefreshKeys) bounds how long a request waits for a forced refresh before continuing with the currently cached keys. Defaults to0(no timeout) to preserve existing behavior.keyRegistryshared by every plugin instance built from the same configuration (keyed on plugin name + keys + JWKS headers + timeout), so one refresh goroutine serves all routes and config reloads no longer orphan live instances.