Skip to content

Commit f5d95ef

Browse files
committed
correct comments
1 parent c7dc715 commit f5d95ef

File tree

5 files changed

+130
-128
lines changed

5 files changed

+130
-128
lines changed

coderd/authz/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ This can be represented by the following truth table, where Y represents *positi
4343

4444
**Permissions** are represented in string format as `<sign>?<level>.<object>.<id>.<action>`, where:
4545

46-
- `sign` can be either `+` or `-`. If it is omitted, sign is assumed to be `+`.
47-
- `level` is either `*`, `site`, `org`, or `user`.
46+
- `negated` can be either `+` or `-`. If it is omitted, sign is assumed to be `+`.
47+
- `level` is either `site`, `org`, or `user`.
4848
- `object` is any valid resource type.
4949
- `id` is any valid UUID v4.
5050
- `action` is `create`, `read`, `modify`, or `delete`.

coderd/authz/action.go

-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
package authz
22

3-
func AllActions() []Action {
4-
return []Action{ActionCreate, ActionRead, ActionUpdate, ActionDelete}
5-
}
6-
73
// Action represents the allowed actions to be done on an object.
84
type Action string
95

coderd/authz/authz.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import "golang.org/x/xerrors"
44

55
var ErrUnauthorized = xerrors.New("unauthorized")
66

7-
// TODO: Implement Authorize
7+
// TODO: Implement Authorize. This will be implmented in mainly rego.
88
func Authorize(subj Subject, obj Resource, action Action) error {
99
// TODO: Expand subject roles into their permissions as appropriate. Apply scopes.
1010
var _, _, _ = subj, obj, action
@@ -22,6 +22,9 @@ func Authorize(subj Subject, obj Resource, action Action) error {
2222
// 1 by 1.
2323
var merged Role
2424
for _, r := range roles {
25+
// Site, Org, and User permissions exist on every role. Pull out only the permissions that
26+
// are relevant to the object.
27+
2528
merged.Site = append(merged.Site, r.Site...)
2629
// Only grab user roles if the resource is owned by a user.
2730
// These roles only apply if the subject is said owner.

0 commit comments

Comments
 (0)