{{ message }}
Repository navigation
feat(oidc): lazy OIDC discovery so startup survives an unreachable issuer - #3551
Open
orkhan-huseyn wants to merge 2 commits into
Open
orkhan-huseyn wants to merge 2 commits into
orkhan-huseyn wants to merge 2 commits into
Conversation
Author
orkhan-huseyn
marked this pull request as draft
October 1, 2026 04:15
orkhan-huseyn
marked this pull request as ready for review
October 1, 2026 04:15
…suer Signed-off-by: Orkhan Huseynli <orkhan.huseyn@outlook.com>
… configurable Signed-off-by: Orkhan Huseynli <orkhan.huseyn@outlook.com>
orkhan-huseyn
force-pushed
the
oidc-lazy-discovery
branch
from
October 10, 2026 13:49
3c6a457 to
3005945
Compare
Contributor
This branch has not been deployed
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
Adds opt-in
--oidc-lazy-discovery(defaultfalse). When the OIDC issuer isunreachable at startup, oauth2-proxy starts anyway with a not-ready provider and
performs OIDC discovery in the background (retrying with exponential
backoff), swapping in the real provider once the issuer is reachable — no
restart needed.
While discovery is pending, provider-independent features keep working (Basic
Auth via
--htpasswd-file, health checks, static upstreams). The readinessendpoint stays healthy so the pod remains in load-balancer rotation; the
/oauth2/startlogin flow returns503until discovery succeeds.The background backoff is configurable via
--oidc-lazy-discovery-initial-interval(default
3s) and--oidc-lazy-discovery-max-interval(default30s).With the flag unset (default), behaviour is unchanged: a single discovery
attempt at startup, failing fast on error.
Motivation and Context
A single failed OIDC discovery call currently aborts startup, so oauth2-proxy
can't come up if the identity provider is briefly unavailable (e.g. both
starting together in Kubernetes) — even when Basic Auth is configured as a
fallback. This makes discovery resilient without changing the default.
Fixes #3487
How Has This Been Tested?
providers/lazy_provider_test.go: not-ready gating (OAuth methods returnErrProviderNotReady,Data()serves a placeholder), becomes-ready against amock issuer, and background-loop cancellation via context.
oauthproxy_lazy_test.go: lazy fallback vs. fail-fast insetupProvider,/readyreturning200while discovery is pending, and/oauth2/startreturning
503while not ready.unreachable/404 issuer and unresolvable DNS; Basic Auth keeps working and the
provider becomes ready once the issuer is reachable.
golangci-lint(v2.11.4): 0 issues;go test -race ./...passes;alpha_config.mdregenerated viamake generate.Checklist: