Decide access to every resource with one shared check

オープン
#9,488 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
リファクタリング
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
scala

調査の方向性

Start by reading the access checks named in the issue: WorkflowAccess and ComputingUnitAccess in common/auth, ResourceAccess in common/resource, plus the computing unit and notebook migration checks. Trace how today's ownership and grants feed the resource lists and checks, and review #9485 for the required contract. Done means every resource access decision uses one function and every kind uses the shared list, grant, and revoke endpoints.

索引モデルが issue の本文から書いたものです。

説明

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
  }

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
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"
  }
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
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 #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 #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 #9485 maps to a level, so a kind can add an operation without adding an access rule (mengw15 in #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
主要言語
Scala
スター
333
フォーク
202
平均マージ
3日 11時間
マージ済み PR(30日)
185

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/texera のほかの issue

apache/texera の issue をすべて見る

似ている issue

Scala の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。