mirror of
https://github.com/agent-substrate/substrate.git
synced 2026-11-12 10:35:06 +08:00
Working on [#1563](https://github.com/agent-substrate/substrate/issues/1563) ## Overview This PR defines the initial OpenFGA authorization model (`internal/authz/model.fga`) and comprehensive test suite (`internal/authz/model_test.fga.yaml`) for Substrate control-plane and data-plane operations. ## Key Features & Design 1. **Global Cluster Scope (Singleton)**: - Modeled as a singleton (`cluster:root`). - `owner`: Can create Atespaces (`can_create_atespace`), and automatically inherits `owner` across all child Atespaces via `owner from parent_cluster`. - `viewer`: Read-only access (`can_get`), allowing cluster-level inspection/listing, and automatically inherits `viewer` across all child Atespaces via `viewer from parent_cluster`. 2. **3-Tier Atespace Governance**: - `owner`: Full administrative control; can set policy (`can_set_policy`), get policy (`can_get_policy`), create templates/actors, update, and delete the Atespace (`can_delete`). - `editor`: Can create templates/actors (`can_create_actor`, `can_create_actor_template`), get/update resources and the Atespace (`can_update`, `can_get`). - `viewer`: Read-only access (`can_get`, `can_get_policy`). All subjects require explicit authentication (no wildcard `user:*`). 3. **Direct Binding Boundaries**: - User role bindings stop at the Atespace boundary. - Child `actor` and `actor_template` instances derive their access directly from `parent_atespace`. 4. **Node Restriction for Credential Minting**: - Links the physical topology graph (`scheduled_worker: [worker]`, `host_node: host_node from scheduled_worker`). - `can_mint_ateom_actor_credential` is restricted exclusively to the active `host_node` running the scheduled worker pod. 5. **Lifecycle Permissions**: - `can_resume`: Ingress routers or Atespace editors can resume actors. - `can_suspend`: Actors' workload identities or Atespace editors can trigger suspend. 6. **Naming Conventions**: - Roles and graph edges are nouns (`owner`, `viewer`, `parent_cluster`, `host_node`). - Permission checks evaluated at runtime consistently use the `can_` prefix (`can_get`, `can_set_policy`, `can_create_actor`, `can_mint_ateom_actor_credential`). ## Verification - **OpenFGA Model Tests**: All 5 test suites (101/101 checks) pass: ```bash docker run --rm -v $(pwd)/internal/authz:/workspace -w /workspace openfga/cli:latest model test --tests model_test.fga.yaml # Tests 5/5 passing, Checks 101/101 passing