bobbai00 opened a new issue, #9488:
URL: https://github.com/apache/texera/issues/9488
### 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.
```mermaid
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:
```mermaid
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
```mermaid
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"
}
```
```mermaid
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
- [x] Refactor / Cleanup
- [ ] DevOps / Deployment / CI
- [ ] Testing / QA
- [ ] Documentation
- [ ] Performance
- [ ] Other
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]