Skip to content

Decide access to every resource with one shared check #9488

Closed as not planned
Closed as not planned

Description

@bobbai00

Merged into #9486 (the access check) and #9484 (the access table) when #9483 was reorganized into five parts.

Task Summary

Access is recorded in ten places and decided in at least five. Ownership lives in the workflow_of_user table for workflows, in an owner_uid column for datasets and models, and in a uid column for the other kinds, while grants live in four *_user_access tables with the same three columns. The checks are written separately: WorkflowAccess and ComputingUnitAccess in common/auth, ResourceAccess in common/resource for datasets and models, a second computing unit check in ComputingUnitAccessResource, and a workflow check in notebook-migration-service. The same sharing endpoints exist four times in three services, environments and warehouses cannot be shared at all, and a list can disagree with a check, as in #9227.

This task records access in one table and decides it with one function, in two phases: first one check over today's data, then one table and one set of sharing endpoints for every kind.

Before

Three of the kinds show the pattern. Models follow datasets, and environments and warehouses record only an owner.

erDiagram
  user ||--o{ workflow_of_user : "owns"
  workflow ||--o{ workflow_of_user : "owned in"
  user ||--o{ workflow_user_access : "is granted"
  workflow ||--o{ workflow_user_access : "shared in"
  user ||--o{ dataset : "owns by owner_uid"
  user ||--o{ dataset_user_access : "is granted"
  dataset ||--o{ dataset_user_access : "shared in"
  user ||--o{ workflow_computing_unit : "owns by uid"
  user ||--o{ computing_unit_user_access : "is granted"
  workflow_computing_unit ||--o{ computing_unit_user_access : "shared in"
  workflow_user_access {
    int uid PK
    int wid PK
    privilege_enum privilege
  }
  dataset_user_access {
    int did PK
    int uid PK
    privilege_enum privilege
  }
  computing_unit_user_access {
    int cuid PK
    int uid PK
    privilege_enum privilege
  }
Loading

Each service decides access with its own code:

flowchart LR
  ds["Dashboard Service"]
  fs["File Service"]
  cs["Computing Unit<br/>Managing Service"]
  acs["Access Control Service"]
  nb["Notebook Migration Service"]
  pw["Environment and<br/>warehouse resources"]
  wa["WorkflowAccess<br/>common/auth"]
  ra["ResourceAccess<br/>common/resource"]
  cua["ComputingUnitAccess<br/>common/auth"]
  cur["ComputingUnitAccessResource<br/>its own check"]
  nwa["WorkflowAccessResource<br/>its own check"]
  own["An owner filter<br/>in each resource class"]
  ds --> wa
  fs --> ra
  cs --> cur
  cs --> cua
  acs --> cua
  nb --> nwa
  pw --> own
Loading

After

erDiagram
  user ||--o{ access : "holds"
  resource ||--o{ access : "grants"
  resource {
    uuid rid PK
    string kind
    bool is_public
  }
  access {
    uuid rid PK
    int uid PK
    string level "own, write or read"
  }
Loading
flowchart LR
  jvm["Every JVM service"]
  ext["Agent service,<br/>gateway"]
  acs["Access Control Service"]
  one["One access function<br/>common/resource"]
  pm["Permission map<br/>from the contract"]
  t[("access")]
  jvm --> one
  ext -- "POST /access/evaluation" --> acs
  acs --> one
  pm -.-> one
  one --> t
Loading
Operation Before After
List GET /access/workflow/list/{wid}, and a copy each for datasets, models and computing units GET /{kind}/{rid}/access
Grant or change PUT /access/workflow/grant/{wid}/{email}/{privilege}, and the same three copies PUT /{kind}/{rid}/access/{uid}
Revoke DELETE /access/workflow/revoke/{wid}/{email}, and the same three copies DELETE /{kind}/{rid}/access/{uid}
Check No endpoint: each service checks access in its own code POST /access/evaluation

Scope

  1. One check over today's data. An access view, keyed by the rid of Give every resource one id and one common record #9487, unites today's owners and grants. One function in common/resource answers both "may this user do this to this resource" and "which resources may this user see", so a list and a check cannot disagree. Every existing check calls it, and POST /access/evaluation gives the same answer to callers outside the JVM, such as the agent service.
  2. One table and one set of sharing endpoints. Owners and grants move into an access table, and every kind is shared through the endpoints above, environments and warehouses included. The old /access/{kind}/... routes become adapters over them, and the old tables remain as views until their last reader moves.
  3. Executions follow their workflow. An execution is checked as the workflow it belongs to, which is what the agent needs to read an execution's outcome (eugenegujing in Proposal: Unify Backend Resource Management On Texera #9395).

The second phase needs the contract of #9485, and a host for the kinds in amber (discussion point 3 of the parent issue). This task does not verify tokens, which is #9486. The agent's own rules (#5268) build on this check, and #9478 can land before it.

Discussion Points

  1. The levels. own, write and read replace privilege_enum (NONE, READ, WRITE) and the separate owner records. A public resource is readable by everyone without a row per user.
  2. Operations of one kind. Executing a workflow or uploading a file to a dataset needs a permission that the contract of Define the resource service's API in one contract and generate code from it #9485 maps to a level, so a kind can add an operation without adding an access rule (mengw15 in Proposal: Unify Backend Resource Management On Texera #9395).
  3. Rules that differ today. For example, a user with read access can leave a shared workflow but not a shared dataset. Each such difference needs one rule, pinned by a test before the code changes.
  4. A policy engine. One table and one function cover a user, a resource and a level. A policy engine such as OpenFGA pays off once groups or projects arrive, and POST /access/evaluation is where it would plug in. My Texera 2.0 prototype used OpenFGA, and needed an outbox, a relay and a second copy of its rules in SQL to filter lists.

Done when every endpoint that reads or changes a resource or its sharing decides access through the one function, and every kind is shared through the same three endpoints.

Task Type

  • Refactor / Cleanup
  • DevOps / Deployment / CI
  • Testing / QA
  • Documentation
  • Performance
  • Other

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions