Conversation
Contributor
Author
|
drafting because the tests suck |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3579 +/- ##
==========================================
+ Coverage 65.61% 65.65% +0.03%
==========================================
Files 407 407
Lines 40246 40300 +54
==========================================
+ Hits 26407 26458 +51
- Misses 11779 11786 +7
+ Partials 2060 2056 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Defer OIDC discovery until the first ValidateToken call to handle the case where the OIDC provider (e.g. an embedded auth server) starts after the token validator is created. This occurs with embedded auth servers running in the same pod, where Kubernetes Service endpoints take time to propagate even after the container is listening. Use a mutex+flag pattern so that failed discovery can be retried on subsequent calls — transient failures should not be permanent. On failure, exponential backoff retries up to 3 attempts with a ~3.5s total window, which handles typical networking propagation delays. Each attempt has a 5-second timeout and respects context cancellation. Add a WithEnvReader functional option to NewTokenValidator for injecting the env.Reader dependency, defaulting to env.OSReader. This eliminates process-wide os.Setenv calls in tests, enabling t.Parallel() on all OIDC-related tests.
5bbe7af to
97d083a
Compare
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.
Implement deferred OIDC discovery for the token validator to handle the chicken-and-egg problem where the authserver handlers may not be ready when the validator is created. This occurs with embedded auth servers running in the same pod, where Kubernetes Service endpoints take time to propagate even after the container is listening.
Discovery is now deferred until the first ValidateToken call using a sync.Once pattern. If discovery fails, exponential backoff retries up to 3 times with a ~3.5 second total window, which handles the typical networking propagation delays. Each attempt has a 5-second timeout and respects context cancellation.
This enables the auth proxy to validate tokens from its own embedded auth server without requiring complex startup sequencing or readiness coordination.