Repository navigation
fix: hide duplicates from non-readers in 409 - #208
Conversation
Registering a service with the URL and API type of a registered one
(POST, or PUT of another service) returned 409 with the registered
service's identifier to every caller, also to users who may not read
it when a deployment requires login for reads (readers recipe).
Name the registered service (serviceId, detail) only if the caller may
get it: the same decision as for GET /services/{serviceId}, via the
route of that request (whether FOCA enforces policies on it) and FOCA's
is_permitted() for its path, with the caller's validated token. Others
get a generic 409 without the service. The spec describes both forms;
serviceId is no longer required.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The access control and API pages and the 0.3.0 release notes say that 409 names the registered service only to users who may read it, and that 409 rather than 201 still tells others the URL is taken. Closes #203 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Identifiers with slashes were routed to other operations (e.g.,
/services/{id}/verification), whose policies then decided. Require the
route of GET /services/{serviceId} for the identifier. Log why a 409
hides the service, next to FOCA's denied check, and let
DuplicateService build the hidden conflict (review findings).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Google-style parsers read paragraphs after Args as part of the last argument (review finding). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThe PR prevents duplicate-service File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #208 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 15 15
Lines 1136 1156 +20
=========================================
+ Hits 1136 1156 +20 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="cloud_registry/ga4gh/registry/permissions.py" line_range="245" />
<code_context>
+ return True
+ # an attribute that Connexion adds
+ request_ctx.connexion_context = connexion_context # type: ignore[attr-defined]
+ return is_permitted()
+
+
</code_context>
<issue_to_address>
**Permission backend error aborts duplicate response**
When the duplicate-service lookup succeeds but FOCA's permission or role backend errors while evaluating the read policy, `is_permitted()` propagates the authorization-backend error, and `_register_service()` has no handler for it, so a duplicate registration returns a 500 instead of the generic 409.
Handle authorization-evaluation failures explicitly, returning only a generic conflict if that is the intended fail-closed response.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and if the permission check incorrectly treats a non-reader as allowed, the 409 response includes the registered service’s identifier and detail, which cannot be undisclosed by reverting. The response still reveals that a duplicate exists, but this change introduces the risk of also exposing which service it is.
Blocking findings: cloud_registry/ga4gh/registry/permissions.py:245
Summary
Registering a service with the URL and API type of a registered one (
POST /services, orPUTof another service) returned409 Conflictwith the registered service's identifier (serviceId, and indetail) to every caller, also to users who may not read services under the readers recipe of "Requiring login for reads".As decided in #203:
409as before, withserviceIdand the identifier indetail.409("A service with the same URL and API type is registered."), withoutserviceIdor other details of the registered service.GET /services/{serviceId}with the caller's token (may_read_service()inpermissions.py). It pushes a request context for thatGET, takes FOCA's decision on whether policies are enforced on its route (only with the login-for-reads patch), and if they are, evaluates them with FOCA'sis_permitted(), using the caller's validated token. Policy evaluation is not reimplemented. Identifiers that aren't routed to that operation (e.g., with slashes) count as not readable.DuplicateServiceresponse) describes both forms;serviceIdis no longer required.docs/access-control.md,docs/api.mdand the 0.3.0 release notes say who gets the identifier, and that409rather than201still tells others that the URL is taken, which can't be avoided while duplicates are rejected.may_read_service()relies on FOCA's internal_enforces_access_control()(as FOCA's ownownership_serverdoes) and on Connexion'sconnexion_contexton the request context, because FOCA has no public helper for the decision on another request. The tests pin the behaviour against the pinned FOCA commit. Proposed follow-up: a public FOCA helper (e.g.,is_permitted(path, method)), so that apps don't need these internals.Verification
pytest -W ignore::DeprecationWarningunder coverage (mongomock; the MongoDB-only tests are skipped locally and run in CI): 983 passed, 211 skipped; coverage 100%.tests/test_access_control.py, forPOSTandPUT:409, also for services they own themselves;a/b,a/verification,a/permissions) count as not readable.pre-commit run --all-files(ruff, mypy, semgrep, gitleaks, actionlint, ast-grep): passed.mkdocs build --strict: passed.python scripts/release_notes.py check docs/releases/0.3.0.md: passed.Review
Full lane (access control). Reviewers: adversarial and quality, 2 rounds.
Round 2 found one docstring placement issue (fixed); no other findings.
Round 1, fixed:
GET /services/{serviceId}counts.409hides the service, next to FOCA's "Access denied" line for the check.DuplicateService.hidden()now builds the generic conflict.Declined review findings
PUTrouting can't create such services, so the branch is covered by the unit test ofmay_read_service().register()builds its payload internally; reading the service back keeps the helper independent of it.Open questions
None.
Closes #203
🤖 Generated with Claude Code