Skip to content

chore: document RBAC usage #14065

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Sep 10, 2024
Prev Previous commit
Next Next commit
make fmt
  • Loading branch information
johnstcn authored and dannykopping committed Sep 10, 2024
commit c2f29d0a3becf6772b630e6f6b9960913cdaf303
8 changes: 5 additions & 3 deletions coderd/rbac/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ These can be found in `coderd/rbac/roles.go`.
| **orgUserAdmin** | Like **userAdmin**, but scoped to a single organization | _(org-level equivalent)_ |
| **orgTemplateAdmin** | Like **templateAdmin**, but scoped to a single organization | _(org-level equivalent)_ |

**Note an example resource indicates the role has at least 1 permission related to the resource. Not that the role has complete CRUD access to the resource.**
**Note an example resource indicates the role has at least 1 permission related
to the resource. Not that the role has complete CRUD access to the resource.**

_\* except some, which are not important to this overview_

Expand Down Expand Up @@ -137,8 +138,8 @@ In our case, we want **members** to be able to CRUD their own frobulators and we
want **owners** to CRUD all members' frobulators. This is how most resources
work, and the RBAC system is setup for this by default.

However, let's say we want **organization auditors** to have read-only access to all organization's
frobulators; we need to add it to `coderd/rbac/roles.go`:
However, let's say we want **organization auditors** to have read-only access to
all organization's frobulators; we need to add it to `coderd/rbac/roles.go`:

```go
func ReloadBuiltinRoles(opts *RoleOptions) {
Expand Down Expand Up @@ -304,6 +305,7 @@ func (q *querier) GetUserFrobulators(ctx context.Context, userID uuid.UUID) ([]d
return fetch(q.log, q.auth, q.db.GetUserFrobulators)(ctx, id)
}
...
```

This states that the `policy.ActionRead` permission is required in this query on
the `ResourceFrobulator` resources, and `WithOwner(userID.String())` specifies
Expand Down