fix(auth): retry issuer metadata discovery and fail startup when the main login provider is unreachable#1904
Merged
Conversation
…main login provider is unreachable
- Run the startup pre-check through openid-client's Issuer.discover instead of a raw fetch: same code path and validation as the authenticator (catches an ingress serving 200 with a non-OIDC body), and each attempt is bounded by openid-client's built-in HTTP timeout so a hanging connection cannot stall backend startup indefinitely (node-fetch v3 has no default timeout). - Parse metadataUrl once before the retry loop so a malformed URL fails immediately instead of burning the retry budget. - Wrap the upstream oidc authenticator (gsOidcAuthenticator) to memoize issuer discovery only on success: a discovery failure after startup is retried on the next login instead of being cached for the process lifetime, closing the window between the startup check and the authenticator's own discovery. - Replace the single-iteration provider loop with an if on gs.authProvider. - Swap the node-fetch dependency for openid-client.
marians
approved these changes
Jul 10, 2026
JS Dependency Audit0 added · 0 removed · 167 total (0 vs base) Projects audited
No change in vulnerabilities compared to the base branch. Full current vulnerability list (167)
|
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.
What this PR does
Makes the main OIDC login provider registration self-healing instead of silently skippable.
auth-backend-module-gschecks the issuer's metadata endpoint before registering the main login provider (gs.authProvider). Previously that check ran once inside a try/catch that logged and skipped registration on failure — so a transient Dex outage at pod startup produced a backend that came up healthy but returned404 Unknown auth providerfor every login until someone manually restarted the pod. This happened on the internal portal today: the pod restarted while Dex was briefly unreachable, and login was broken for ~6 hours.Changes:
waitForIssuerMetadata(), which retries with exponential backoff (5 attempts, 1s → 8s, ~15s total) to absorb transient blips. Retry attempts log atinfo(notwarn) so recovered retries don't create Sentry issues.Simply dropping the pre-check is not an option: the upstream oidc authenticator performs issuer discovery once and caches a rejected discovery promise permanently, which would trade the permanent 404 for a permanent 500.
The swallow-and-continue behaviour remains only conceptually for non-critical providers; the OIDC loop only ever contains the main provider (per the broker-only cluster auth model), and
mcp-*provider registration is unchanged.Testing
waitForIssuerMetadata: immediate success, recovery after retries with backoff sequence, non-ok HTTP responses, exhaustion, and nowarn/errorlogs from retries.yarn workspace @giantswarm/backstage-plugin-auth-backend-module-gs test— 16 passed.yarn tscclean for the touched package (pre-existing unrelated errors inai-chaton main).