Add registry AuthDefaulter extension point for OIDC discovery#5255
Open
reyortiz3 wants to merge 2 commits into
Open
Add registry AuthDefaulter extension point for OIDC discovery#5255reyortiz3 wants to merge 2 commits into
reyortiz3 wants to merge 2 commits into
Conversation
When `thv config set-registry <url>` is run without --issuer and
--client-id, or PUT /api/v1beta/registry/{name} is called without
an auth object, the registry has no OAuth configured. Downstream
consumers (e.g. enterprise builds) want to fill those in from an
external source — typically an OIDC discovery document — so admins
do not have to distribute issuer/client_id out of band.
This adds a pluggable AuthDefaulter:
- pkg/registry/auth_defaulter.go: AuthDefaulter type, Register and
Active accessors, and a ResolveAuthDefaults helper.
- cmd/thv/app/config.go: set-registry CLI calls ResolveAuthDefaults
when both --issuer and --client-id are omitted.
- pkg/api/v1/registry.go: PUT /api/v1beta/registry/{name} calls
ResolveAuthDefaults when the request body omits auth.
OSS builds register no defaulter and keep the existing behavior
(no auth when none is supplied). The defaulter only fires when
explicitly registered, and an explicit empty auth still wins over
the defaulter.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The defaulter branch pushed updateRegistry's cyclomatic complexity from 15 to 16, tripping gocyclo. Move the "decide which auth to apply and apply it" block into applyRegistryAuth, and translate its failure modes through writeRegistryAuthError. Behavior is unchanged: explicit auth still applies verbatim, no auth still falls back to the AuthDefaulter then to clearing, and a clear failure still returns 500 while a processAuthUpdate failure still returns 400. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5255 +/- ##
==========================================
+ Coverage 67.99% 68.06% +0.07%
==========================================
Files 616 617 +1
Lines 63005 63037 +32
==========================================
+ Hits 42840 42909 +69
+ Misses 16963 16924 -39
- Partials 3202 3204 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
blkt
approved these changes
May 12, 2026
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.
Summary
thv config set-registry <url>andPUT /api/v1beta/registry/{name}currently require the caller to pass--issuer/--client-id(or anauthbody) explicitly. Downstream consumers (enterprise builds, GUIs, future managed deployments) want to fill these in automatically from an OIDC discovery document, but there is no extension point to plug that resolver into either entry point.registry.AuthDefaulterinpkg/registry/. When the user/API caller omits auth, the CLI and the API handler consult the registered defaulter (if any) and use what it returns. OSS builds register no defaulter and behave exactly as before.Type of change
Test plan
go test ./pkg/registry/... ./pkg/api/v1/... ./cmd/thv/app/...)TestResolveAuthDefaults,TestRegisterAuthDefaulter(pkg/registry)TestUpdateRegistry_AuthDefaulterFillsMissingAuth(pkg/api/v1, uses a mocked OIDC discovery server)task test-e2e) — not run; behavior unchanged for OSS buildsDoes this introduce a user-facing change?
No (for OSS). The new extension point is dormant unless a build registers a defaulter via
registry.RegisterAuthDefaulter. Existing CLI/API contracts are unchanged: explicit--issuer/--client-idorauthbody still wins, and omitting them with no defaulter registered still produces a registry with no OAuth (the prior behavior).Special notes for reviewers
RegisterAuthDefaulter(nil)clears the active defaulter (needed by tests).(issuer, clientID)only — audience and scopes still come from the caller's request or the defaults already inpkg/registry/auth.🤖 Generated with Claude Code