DependencyTrack / DependencyTrack/dependency-track

Normalize permission model

Open
#6,189 13 comments 0 reactions 0 assignees View on GitHub
breaking change enhancement size/L
Dominant language
Java
Stars
4.2k
Forks
811
Avg merge
8h 39m
Merged PRs (30d)
237

Description

### Current Behavior

Currently, the `PERMISSION` table is very simplistic:

```mermaid
erDiagram
PERMISSION {
BIGINT ID PK
TEXT NAME
TEXT DESCRIPTION
}
```

Available permissions are defined in the [`Permissions`](https://github.com/DependencyTrack/hyades-apiserver/blob/a30a0a09e2c7995a780cc86d56e0ed49c2ff6df9/src/main/java/org/dependencytrack/auth/Permissions.java#L29-L66) class.

### Proposed Behavior

Normalize the permission model, such that subject and verb are separated:

```mermaid
erDiagram
PERMISSION {
BIGINT ID PK
TEXT SUBJECT
TEXT VERB
}
```

The following legacy permissions:

* PORTFOLIO_MANAGEMENT
* PORTFOLIO_MANAGEMENT_CREATE
* PORTFOLIO_MANAGEMENT_READ
* PORTFOLIO_MANAGEMENT_UPDATE
* PORTFOLIO_MANAGEMENT_DELETE

Would translate to:

| SUBJECT | VERB |
|:--------|:-----|
| PORTFOLIO | ALL |
| PORTFOLIO | CREATE |
| PORTFOLIO | READ |
| PORTFOLIO | UPDATE |
| PORTFOLIO | DELETE |

We could further assign ranks to each verb, such that `UPDATE` implies `READ`, and `ALL` implies all verbs. This could be achieved by defining verbs in an [enum](https://www.postgresql.org/docs/current/datatype-enum.html), or a separate VERB table.

With the above in place, queries could use efficient "has at least verb X on subject Y" predicates. This roughly resembles GitLab's model of "access levels" (see https://github.com/DependencyTrack/hyades/issues/1632#issuecomment-2726921657).

### Checklist

- [x] I have read and understand the [contributing guidelines](https://github.com/DependencyTrack/hyades/blob/main/CONTRIBUTING.md#filing-issues)
- [x] I have checked the [existing issues](https://github.com/DependencyTrack/hyades/issues) for whether this enhancement was already requested

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.