Repository navigation
Conversation
Use FOCA's access control (Casbin) to implement the agreed permission
model:
- Anyone can read services, service types and service info: the read
operations of the GA4GH specifications are made public via additions
merged into them, so the vendored specifications stay unchanged.
- Any LS Login user can register a service (POST) and becomes its
owner. Owners can update and delete their services and grant other
users the roles owner or maintainer (update only) via new endpoints
/services/{serviceId}/permissions[/{userId}].
- Members of ECP_CLN:ADMIN are admins and can do everything, including
setting the service info and registering services with chosen
identifiers (PUT of a new service). LS Login provides entitlements
via user info only, so they are added to the token claims via FOCA's
security.auth.userinfo_claims.
Policies use FOCA's reference model for resource-scoped roles and are
added on startup; roles on services are revoked when they are deleted.
BREAKING CHANGE: non-admins can no longer modify or delete services
they do not own or maintain, set the service info, or register
services via PUT. Existing services have no owner (see #63).
Closes #62
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reviewer's GuideIntroduces FOCA/Casbin-backed owner-based access control for registry services, with public reads, authenticated ownership and maintenance workflows, admin entitlement support, permission-management endpoints, lifecycle cleanup, OpenAPI/README documentation, and end-to-end mocked identity tests. Sequence diagram for service registration and ownership assignmentsequenceDiagram
actor User
participant API as Registry API
participant RegisterService
participant Policy as FOCA/Casbin
participant Rules as policy_rules
User->>API: POST /services
API->>Policy: Enforce POST /services
Policy->>Rules: Evaluate authenticated user policy
Rules-->>Policy: Allow
API->>RegisterService: register_metadata()
RegisterService-->>API: service id
API->>Policy: add_owner(serviceId)
Policy->>Rules: Store owner role for service resource
Rules-->>Policy: Owner stored
API-->>User: Service id
Sequence diagram for role management on a servicesequenceDiagram
actor Owner
participant API as Registry API
participant Policy as FOCA/Casbin
participant Rules as policy_rules
Owner->>API: PUT /services/{serviceId}/permissions/{userId}
API->>Policy: Enforce permission-management policy
Policy->>Rules: Check owner role or admin role
Rules-->>Policy: Allow
API->>Policy: add_resource_role(userId, role, service)
Policy->>Rules: Replace other service role
Rules-->>Policy: Role stored
API-->>Owner: Permission
Flow diagram for service access-control rolesflowchart LR
User[Authenticated user] -->|POST /services| Owner[Owner]
Owner -->|PUT| Service[Service]
Owner -->|DELETE| Service
Owner -->|GET PUT DELETE| Permissions[Service permissions]
Maintainer[Maintainer] -->|PUT| Service
Admin[Admin entitlement] -->|All operations| Service
Admin -->|POST /service-info| ServiceInfo[Service info]
Public[Anyone] -->|GET| Service
Public -->|GET| ServiceInfo
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Use FOCA options proposed for 0.14.0: policy rules are set via security.access_control.policies instead of being added in code on startup (elixir-cloud-aai/foca#311), and the permission endpoints are routed to their own controller module via x-openapi-router-controller instead of being re-exported from the server module (elixir-cloud-aai/foca#310). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Connexion logs the status code with %d, which fails for the string "201" and makes the access control test fail under pytest. Co-Authored-By: Claude Opus 5.5 <[email protected]>
With FOCA 0.14, configured policies are managed on startup and cannot be changed via the permissions API. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 20, 2026
Closed
uniqueg
added a commit
that referenced
this pull request
Oct 20, 2026
- Public reads; writes need roles on a service (owner, maintainer) or
the admin role, via FOCA's access control (Casbin)
- Owners manage roles: GET/PUT/DELETE /services/{id}/permissions
- GET /me: the current user's ID, admin flag and roles
- Display names from LS Login user info, scoped per service
- Removing or demoting the last owner returns 409
- Startup fails without an admin group mapping, unless
custom.access_control.require_admin is false; Helm render fails too
- Audience verification on by default; Docker Compose uses a
development overlay (config.dev.yaml)
- Registration and role changes roll back on failures
Replaces #66 (commits re-applied, author preserved, signed).
Closes #62
BREAKING CHANGE: writes need roles. Only owners (and maintainers, for
updates) can change a service; only admins can set the service info
or create services with chosen IDs. Existing services have no owner,
so only admins can change them.
BREAKING CHANGE: deployments must set security.auth.audience and map
an admin group to admin in security.access_control.group_mapping, or
set custom.access_control.require_admin: false. Otherwise the app
refuses to start, and the Helm chart fails to render without the
mapping.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Member
Author
|
Superseded by #106, which re-applies these commits on top of |
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
Implements the permission model of #62 with FOCA's access control (Casbin). It is stacked on #65 (FOCA 0.14.0 upgrade) and needs these FOCA PRs, planned for FOCA 0.14.0: elixir-cloud-aai/foca#308 (
security.auth.userinfo_claims), elixir-cloud-aai/foca#310 (operations keep their ownx-openapi-router-controller) and elixir-cloud-aai/foca#311 (security.access_control.policies).Mostly configuration, plus minimal code for what is app-specific (who owns which service):
GETon services, a service, service types and service info need no token. Thesecurity: []overrides are inadditions.openapi.yamland merged into the GA4GH operations, so the vendored specifications are unchanged.POST /services) and becomes its owner (add_owner()after registration). Owners can update and delete their services.GET /services/{serviceId}/permissions,PUTandDELETE /services/{serviceId}/permissions/{userId}(body{"role": "owner" | "maintainer"}) let owners grant and revoke roles by user ID (sub). Granting a role replaces the user's other role on the service.PUT), but not delete a service or manage its permissions.ECP_CLN:ADMIN(entitlementurn:geant:lifescience-ri.eu:group:elixir:ECP_CLN:ADMIN#aai.lifescience-ri.eu, mapped to roleadmin) can do everything, includingPOST /service-info(admin only) and registering services with chosen IDs (PUTof a new service). LS Login access tokens do not containeduperson_entitlement, so it is taken from user info viauserinfo_claims(cached per token for 5 minutes).cloud_registry/access_control/model.conf); the five policy rules are set inconfig.yaml(security.access_control.policies) and added on startup unless stored already. The permission endpoints are routed toga4gh.registry.permissions. Rules are stored in collectionpolicy_rulesof databaseserviceStore. Roles on a service are revoked when it is deleted.RegisterServicenow distinguishes newly created services (upserted_id) from replaced ones;modified_countalone would have made a maintainer replacing a service with identical content its owner.Verification
pytest: 40 passed (Python 3.12, FOCAdevwith foca#308, docs: stop overriding the org contributing guide #309, feat(chart): set the number of app replicas #310 and Reject extra fields in service organizations #311 merged locally; also with the pinnedmongomock==4.0.0). Newtests/test_access_control.pycreates the app from the realconfig.yaml(in-memory MongoDB, mock LS Login with RS256-signedat+jwttokens and entitlements via user info only) and covers every permission path: public reads,401without token, creator becomes owner,403for others onPUT/DELETE/permissions, admin can do everything, service info admin only, maintainerPUTbut notDELETE, granting/replacing/revoking roles, invalid role/user ID (400), unknown service (404),PUT-create admin only, roles removed with the service. Withoutuserinfo_claims, 7 of these 11 tests fail; without the configured maintainer rule, the maintainer test fails.flake8,black --check: pass.mypy cloud_registry(mypy 2.4): pass.Not verified: a deployment (Docker/compose, Helm) and real LS Login tokens against a running instance; #62 asks for a test deployment. CI does not run yet: the workflow only runs for PRs to
dev, andfoca>=0.14.0is not on PyPI yet. Retarget this PR todevafter #65 is merged.Open questions
ECP_CLN:ADMINis mapped. Admins' user info also listsurn:geant:elixir-europe.org:group:elixir:ECP_CLN:ADMIN#perun.elixir-czech.cz; add it togroup_mappingif needed.GETresponses (would publish user IDs; owners and admins can list them via/permissions), and preventing owners from removing the last owner (admins can still fix that).🤖 Generated with Claude Code
Summary by Sourcery
Implement owner-based access control for registry services with administrator support and permission-management APIs.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests: