Add optional OIDC bearer auth on remote/virtual config writes #136
Reference in New Issue
Block a user
Delete Branch "benvin/oidc-write-auth"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Remote and virtual configuration writes are unauthenticated, so anything that can reach the API can repoint or delete repos. Vault identity OIDC tokens give callers a verifiable identity.
ARTIFACTAPI_OIDC_ISSUER/ARTIFACTAPI_OIDC_AUDIENCE; unset issuer keeps auth off/api/v2/remotesand/api/v2/virtuals, 401 otherwise/v2opensub; allowAuthorizationin CORScontext.WithoutCancel(ctx)is applied to the already-timeboxed ctx, so it drops the 10s deadline too;http.DefaultClienthas no timeout, so a hung issuer blocks discovery indefinitely while holdingb.mu, wedging every gated write (reproduced: 25s hang against a stalled issuer) → build the long-lived ctx fromcontext.Background()for the provider, and put the 10s timeout on a dedicatedhttp.Client(viaoidc.ClientContext) or on a separate request-scoped discovery attempt.CutPrefix(..., "Bearer ")is case-sensitive and does not trim whitespace (RFC 7235 scheme is case-insensitive) → usestrings.EqualFoldon the scheme andTrimSpacethe token.iss, or a lowercase/emptyBearerheader → add negative cases.|| b.discoveringreturns errIssuerUnavailable); terraform writes in parallel (default 10), so the first apply on a fresh pod sees spurious 503s → make concurrent callers wait for the in-flight discovery (singleflight or a done channel, bounded by the 10s client timeout) and fail fast only during post-failure backoff; do not hold b.mu while waiting.inflightis only cleared afteroidc.NewProviderreturns, with no defer/recover; a panic in discovery (chi Recoverer swallows it) leavesinflightset anddonenever closed, so every later caller blocks until its own request ctx ends and the backoff path is never reached, until restart → run the discovery in a func withdeferthat clearsinflight, closesdoneand recordsfailedAton any exit.No findings.