Repository navigation
feat: allow reads by policy for login setups - #187
Conversation
Name the API specification (`registry`) and the policies, so that overlays change single entries by name (FOCA 0.17 named entries), and add policies that allow GET on the read endpoints for any authenticated user. They are only evaluated once a deployment requires login for reads, which the patch shipped with the app does (`api/patches/login-for-reads.yaml`). Document the recipe, with a test that applies it from the docs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Name the read rules by operation (list-services, get-service, get-service-verification, list-verifications), anchor the docs tests on titled YAML blocks, reuse one verified service per test, map only readers in the docs example (keeping the deployment's admin groups), note that list policies need the read rules, and tidy the docs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideIntroduces an opt-in FOCA spec-patch workflow for requiring login on registry reads, backed by named API and policy entries that overlays can modify individually. The default remains publicly readable; when enabled, authenticated users can read through new default policies, while metadata and existing protected operations retain their prior access behavior. Documentation, package installation, and end-to-end tests cover the new deployment model. Sequence diagram for requiring login on registry readssequenceDiagram
participant Client
participant RegistryAPI
participant FOCA
participant PolicyEngine
Client->>RegistryAPI: GET /services
RegistryAPI->>FOCA: Validate operation security
alt Login-for-reads patch enabled
FOCA-->>Client: 401 Unauthorized
FOCA->>PolicyEngine: Evaluate list-services
PolicyEngine-->>FOCA: Authenticated user allowed
FOCA-->>Client: 200 OK
else Public reads
FOCA-->>Client: 200 OK
end
Entity relationship diagram for named API and access-control entrieserDiagram
API_SPEC ||--o{ SPEC_PATCH : receives
API_SPEC {
string name_registry
}
SPEC_PATCH {
string path_login_for_reads
string security_bearerAuth
}
ACCESS_CONTROL ||--o{ POLICY_RULE : contains
ACCESS_CONTROL {
string policies_named
}
POLICY_RULE {
string name_list_services
string name_get_service
string name_get_service_verification
string name_list_verifications
}
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #187 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 14 14
Lines 906 906
=========================================
Hits 906 906 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Sourcery withdrew this approval because the latest commits introduced blocking findings.
Summary
This PR lets deployments require login for reads, so that any logged-in user can read and anonymous users get
401(instead of "admins only"). It uses FOCA 0.17's spec patches and named entries, from the FOCA dev pin of #184.Named entries:
api.specsis now a named spec,registry.security.access_control.policiesare now named rules, so overlays can change, add or remove single rules by name (nullremoves one).Default read rules allow
GETfor any authenticated user (*) on the read endpoints:list-servicesget-service, which also covers/services/types, since keyMatch2 matches it with/services/:idget-service-verificationlist-verificationsThere is no rule for
/services/:id/permissions. FOCA only evaluates these rules for operations that require authentication, so nothing changes while reads are public, which is the default.Shipped patch:
cloud_registry/api/patches/login-for-reads.yaml, installed as package data. It setssecurity: [bearerAuth: []]on all public reads exceptGET /service-info. Operators apply it with a 5-line overlay, or with the chart'sconfigvalue:api.specs.registry.patches: [api/patches/login-for-reads.yaml]. Relative paths resolve against the base config directory, so no file needs to be mounted.Docs:
docs/access-control.md(the patch is included via snippets), with FOCA's "With great power comes great responsibility" warning;readerrole;configuration.md,api.md,README.mdand the 0.3.0 notes.Tests: the docs tests parse the overlays from the docs and apply them:
401;200;/service-info,/openapi.jsonand/ui/stay public;The readers example is tested too, and so are public reads by default.
Closes #168
How it was verified
coverage run -m pytest: 1066 passed, 100% coverage (rebased on dev with build: test against FOCA 0.17 from dev #184).pre-commit run --all-files: passed.mkdocs build --strict: passed.docker build: the patch is installed in the image.helm templatewith the overlay inconfig: rendered as given.Review
registry-adminsmapping. The recipe now notes that overlays giving the policies as a list must include the read rules. The reviewer also probed:/permissions;Declined review findings
None.
Open questions
None.
Notes for the user and deployers
security.access_control.policiesorapi.specsas lists still work, and replace the base config's entries completely, as before. FOCA refuses to start if a later overlay gives named entries for them. Such deployments must add the read rules to their list if they require login for reads.🤖 Generated with Claude Code
Summary by Sourcery
Enable deployments to require login for read operations through a documented API specification overlay while preserving public reads by default.
New Features:
Enhancements:
Build:
Documentation:
Tests: