Repository navigation
fix: close the 0.6.0 review gaps - #275
Conversation
Warn on startup if the rule of owners' roles of groups is changed or removed, but other rules (e.g., owners-change-permissions, which also covers groups since 0.6.0) still let owners grant or revoke roles of groups. Refs #268 Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Upgrade guide and access control: owners-change-permissions also covers the roles of groups; how to restrict owners to users. - Admin mode with web UIs: deploy a UI that sends X-Request-Roles first, or set opt_in_roles: [] until then. - Me.user_id: namespaced by issuer with several issuers. - Renames: change roles via the registry's endpoints, not FOCA's permissions API, while services are renamed. - Chart schema comment: FOCA 0.18. Closes #268 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Rules for the roles of groups only (e.g., the changed rule itself) are the deployment's choice; warn only of rules that cover the roles of both users and groups. Test other roles, any user, and GET-only rules. Refs #268 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Name the options for issuers whose namespaces contain slashes, and keep the details in the access control docs only. Refs #268 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideThis PR closes the 0.6.0 pre-release review gaps by adding startup validation for unsafe owner permission overlays, documenting migration and admin-mode behavior, clarifying namespaced user IDs and rename-safe permission APIs, and adjusting typing and chart metadata configuration. Sequence diagram for startup owner-permission overlay warningsequenceDiagram
participant App
participant Config as ConfigParser
participant Casbin as Casbin
participant Logger
App->>Config: parse_yaml(BASE_CONFIG)
Config-->>App: OWNER_GROUP_RULE base policy
App->>Casbin: key_match2(group_path, rule_path)
App->>Casbin: key_match2(user_path, rule_path)
alt group rule changed or removed
Casbin-->>App: matching owner or wildcard PUT/DELETE rules
App->>Logger: warning via warn_owner_rules()
else base group rule unchanged
App->>App: skip warning
end
Sequence diagram for admin mode in web UIssequenceDiagram
actor Admin
participant UI
participant Registry
Admin->>UI: Enable admin mode
UI->>Registry: Request with X-Request-Roles: admin
Registry-->>UI: Process request as admin
UI-->>Admin: Show admin operation
alt UI does not send X-Request-Roles
Admin->>Registry: Request without admin header
Registry-->>Admin: Admin role unavailable
end
Flow diagram for restricting owners to user rolesflowchart TD
A[Change or remove owners-change-group-permissions] --> B[Also redefine owners-change-permissions]
B --> C{Allow roles for users only?}
C -->|Yes| D[Use permissions/:user]
C -->|Namespaced issuers with slash| E[Add a rule per namespace]
D --> F[Groups path permissions/groups/group is not matched]
E --> F
C -->|No| G[Remove or restrict the owner rule]
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
# Conflicts: # cloud_registry/app.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #275 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 20 20
Lines 1989 2008 +19
=========================================
+ Hits 1989 2008 +19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 3 issues
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="661" />
<code_context>
+ if len(rule) >= 4
+ and rule[:2] in (["p", "owner"], ["p", "*"])
+ and key_match2(path, rule[2])
+ and key_match2(user_path, rule[2])
+ and any(re.fullmatch(f"(?:{rule[3]})", method) for method in METHODS)
+ }
</code_context>
<issue_to_address>
**Group-role grants go unreported**
When the group rule is changed or removed and a customized owner policy matches group paths and valid user IDs, including slash-containing issuer-namespaced IDs, but not the synthetic `/permissions/user` path, `warn_owner_rules()` tests only the synthetic user path, so `key_match2()` rejects the policy and startup emits no warning even though owners can still change those group roles.
Check owner policies against valid group paths and user IDs rather than only the synthetic user path.
</issue_to_address>
### Comment 2
<location path="cloud_registry/ga4gh/registry/permissions.py" line_range="652" />
<code_context>
+ policies = get_config().security.access_control.policies or []
+ if base in policies:
+ return
+ path = base[2].replace(":id", "service").replace("*", "group")
+ user_path = path.replace("/groups/group", "/user")
+ allowing = sorted(
</code_context>
<issue_to_address>
**Service-specific grants go unreported**
When an overlay changes or removes the group rule but retains an owner or `*` rule scoped to a literal service ID other than `service`, `warn_owner_rules()` checks only the sample path containing `service`, so `key_match2()` misses the rule and startup emits no warning even though owners can still change group roles on that service.
Check owner policies against service-specific paths rather than only the sample path containing `service`.
Also at `cloud_registry/ga4gh/registry/permissions.py:660-661`.
</issue_to_address>
### Comment 3
<location path="docs/api.md" line_range="201-204" />
<code_context>
used in URLs (as for `PUT`, see [Registrations](#registrations); also
slashes) or in roles (commas, line breaks), with `400 Bad Request`.
+The registry's permission endpoints (`/services/{serviceId}/permissions/...`)
+wait for renames, but FOCA's permissions API (for admins:
+`/admin/access-control/permissions`) doesn't: grant and revoke roles on
+services via the registry's endpoints, or not while the service is renamed
+(roles changed meanwhile may be lost, or left on the old identifier).
+
</code_context>
<issue_to_address>
**Permissions read during renames**
When a permissions GET for the target runs after the service document is moved but before `_move_roles()` copies the source roles, `getServicePermissions()` checks that the target service exists and then reads roles without waiting for the rename. It returns an empty or partial permission list before `_move_roles()` copies the source roles, so callers see roles missing despite the documentation saying the endpoints wait.
Make permission reads wait for renames, or narrow the documentation to say only permission writes wait.
</issue_to_address>Sourcery assessment
Approval pending. 3 findings to address first.
Blocking findings: cloud_registry/ga4gh/registry/permissions.py:661, cloud_registry/ga4gh/registry/permissions.py:652, docs/api.md:204
Rules may cover namespaced user identifiers but not bare ones; check several example users. Say that only changes of roles wait for renames. Refs #268 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Closes the gaps that the pre-release review of 0.6.0 found in docs and config checks (M1 and lows).
owners-change-permissionsto/services/:id/permissions/*, which also matches/permissions/groups/<group>, so 0.5.0 overlays that removed onlyowners-change-group-permissionslet owners grant and revoke roles of groups again.docs/upgrading.md(From 0.5.0, step 5) anddocs/access-control.md: such overlays must also changeowners-change-permissions; how to let owners grant roles to users but not groups (.../permissions/:user, as in 0.5.0), and what that misses with namespaced issuers (namespaces with slashes) and how to cover those.warn_owner_rules()): if the rule of groups is changed or removed, the app warns of configured rules for owners or any user that still allowPUT/DELETEon the roles of both users and groups (checked with Casbin'skeyMatch2and the act regex, for named and list policies). Rules for groups only, other roles andGETare not warned of.X-Request-Rolesfirst, or setopt_in_roles: []until it does (docs/access-control.md#admin-mode, linked from the upgrade step).Me.user_id(L1): namespaced by issuer with several issuers; users give this exact value to owners./admin/access-control/permissionsdoesn't;docs/api.mdsays to use the registry's endpoints, or not while a service is renamed.$comment(L4): FOCA 0.18.Closes #268
Verification
Tests first for the warning (
tests/test_access_control.py):test_owner_rules_warning(15 configurations: unchanged, groups removed, both removed, users as in 0.5.0, usersPUTonly, group rule kept, users removed, list policies with and without group coverage, usersGETonly, maintainers, any user, users of a namespace only, groupsPUTonly) andtest_owner_rules_groups(with only the rule of groups removed, owners still grant roles to groups:200; with users as in 0.5.0:403).Locally (Python 3.13):
coverage run -m pytest(mongomock): 1422 passed, 257 skipped (Helm not installed), coverage 100%pytestagainst MongoDB 7.0.34 (MONGODB_TEST_URI): 1412 passed, 255 skippedpre-commit run --all-files(ruff, semgrep, gitleaks, actionlint, ast-grep, mypy): passedmkdocs build --strict: passedDeclined review findings
config.yamlwith FOCA'sConfigParser.parse_yamlto get the base rule (quality, medium): kept, so the base rule has one source; the path and the coupling are documented (BASE_CONFIG), and every app test would fail at startup if the key moved.warn_owner_rules()with a patched config (quality, medium): the 13 startup cases cover the subjects, roles, methods and list form through the real config pipeline; a unit test would duplicate them.Open questions
None.
🤖 Generated with Claude Code