Repository navigation
Part 1: Add registry access gate and publish/delete claim validation - #649
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #649 +/- ##
==========================================
+ Coverage 59.03% 59.06% +0.03%
==========================================
Files 100 100
Lines 9393 9496 +103
==========================================
+ Hits 5545 5609 +64
- Misses 3375 3407 +32
- Partials 473 480 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
6 tasks done
Member
Author
|
How it was tested: Authorization E2E Test SummaryTest Categories
User Personas
How to Rundocker compose -f docker-compose-authz.yaml up --build -d
./examples/authz-test/test-authz.sh
docker compose -f docker-compose-authz.yaml down -v |
rdimitrov
force-pushed
the
registry-access-gate
branch
from
April 1, 2026 05:31
7e5bb77 to
f3a813b
Compare
blkt
reviewed
Apr 1, 2026
blkt
left a comment
Contributor
There was a problem hiding this comment.
There are a couple issues that need attention.
rdimitrov
force-pushed
the
registry-access-gate
branch
from
April 1, 2026 12:22
f3a813b to
0a0084d
Compare
Enforce JWT claim-based authorization on consumer read endpoints and entry publish/delete operations: - Registry access gate: consumer endpoints now check the registry's claims against the user's JWT. Returns 403 if the caller's claims do not cover the registry's claims. Anonymous mode and super-admin bypass the check. - Publish subset validation: the publish endpoint now validates that request claims are a subset of the publisher's JWT claims, preventing privilege escalation. - Delete authorization: the delete endpoint validates that the caller's JWT claims cover the entry's stored claims before allowing deletion. Infrastructure added: - ErrClaimsInsufficient sentinel error - Roles-in-context (ContextWithRoles/RolesFromContext/IsSuperAdmin) - Shared authz helpers (validateClaimsSubset, validateClaimsSubsetBytes) - WithJWTClaims service option for publish/delete paths Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
blkt
approved these changes
Apr 2, 2026
blkt
force-pushed
the
registry-access-gate
branch
from
April 2, 2026 09:06
0a0084d to
7859ecd
Compare
lujunsan
approved these changes
Apr 2, 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
Enforces JWT claim-based authorization on two paths that were previously unprotected:
/registry/{reg}/v0.1/...) now check the registry'sclaimsfield against the user's JWT before returning data. Returns 403 if the caller's claims don't cover the registry's claims.POST /v1/entriesvalidates that request claims are a subset of the publisher's JWT claims, preventing privilege escalation (a user can't publish entries with broader visibility than their own identity allows).DELETE /v1/entries/{type}/{name}/versions/{ver}validates that the caller's JWT claims cover the entry's stored claims before allowing deletion.Context
The design plan requires claim-based authorization at multiple levels. Per-user entry filtering was already implemented, but the registry-level access gate and write-path claim validation were missing:
lookupRegistryID()fetched the registry row (which includesclaims) but discarded them — returning only the UUIDDesign decisions
WithJWTClaimsis separate fromWithClaims:WithClaimscarries the request body claims (what the publisher wants on the entry).WithJWTClaimscarries the publisher's JWT claims (who they are). These are compared — request claims must be ⊆ JWT claims.callerClaimsis nil (anonymous auth), all claim checks are skipped. This preserves the existing no-auth development experience.ContextWithRoles.IsSuperAdmin(ctx)checks for the super-admin role and bypasses claim validation.lookupRegistryIDandcheckRegistryExistsbecame dead code after all call sites switched to the gated variants — removed rather than keeping unused code.Shared infrastructure added
ErrClaimsInsufficientservice.goContextWithRoles/RolesFromContext/IsSuperAdminauth/claims.govalidateClaimsSubset/validateClaimsSubsetBytesservice/db/authz.goWithJWTClaimsoptionoptions.goWhat this doesn't cover
Test plan
validateClaimsSubsethelpers (17 cases inauthz_test.go)registry_gate_test.go— nil claims, matching, non-matching, anonymous bypass, super-admin bypass, not-found)publish_claims_test.go— JWT superset, JWT insufficient, anonymous, nil request claims)routes_test.go— ListServers, ListVersions, GetVersion)task lint-fix— 0 issuestask test— all tests pass🤖 Generated with Claude Code