Skip to content

Commit

Permalink
fix(auth model): assignee missing from each type for roles (#1444)
Browse files Browse the repository at this point in the history
* fix(auth model): assignee missing from each type for roles

* test(fgatests): add all assignee tests

* feat(authmodel): generate auth model

* chore(make): rename make target auth-model-json
  • Loading branch information
ale8k authored Nov 19, 2024
1 parent ab98ccc commit 6738458
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 505 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ load-rock:
$(eval jimm_version := $(shell cat ./rocks/jimm.yaml | yq ".version"))
@sudo /snap/rockcraft/current/bin/skopeo --insecure-policy copy oci-archive:jimm_${jimm_version}_amd64.rock docker-daemon:jimm:latest

auth-model-json:
fga model transform --file ./openfga/authorisation_model.fga > ./openfga/authorisation_model.json
test-auth-model:
fga model test --tests ./openfga/tests.fga.yaml

Expand Down
4 changes: 1 addition & 3 deletions openfga/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ go install github.com/openfga/cli/cmd/fga@latest
## Adding / modifying [to] the authorsation model
1. Open the authorisation_model.fga
2. Make your modification
3. Open the Command Pallette using Ctrl+Shift+P (Windows) or Command+Shift+P (OSX)
4. Select OpenFGA: Transform DSL to JSON
5. Save the file over the existing authorisation_model.json
3. Run: `make transform-auth-model`
6. Add tests to tests.fga.yaml - Learn more [here](https://openfga.dev/docs/modeling/testing)
7. Run them via: `make test-auth-model`

Expand Down
49 changes: 25 additions & 24 deletions openfga/authorisation_model.fga
Original file line number Diff line number Diff line change
@@ -1,42 +1,43 @@
model
schema 1.1

type applicationoffer
relations
define administrator: [user, user:*, group#member] or administrator from model
define consumer: [user, user:*, group#member] or administrator
define model: [model]
define reader: [user, user:*, group#member] or consumer
type user

type cloud
type role
relations
define assignee: [user, user:*, group#member]

type group
relations
define administrator: [user, user:*, group#member] or administrator from controller
define can_addmodel: [user, user:*, group#member] or administrator
define controller: [controller]
define member: [user, user:*, group#member]

type controller
relations
define administrator: [user, user:*, group#member] or administrator from controller
define audit_log_viewer: [user, user:*, group#member] or administrator
define controller: [controller]
define administrator: [user, user:*, group#member, role#assignee] or administrator from controller
define audit_log_viewer: [user, user:*, group#member, role#assignee] or administrator

type model
relations
define administrator: [user, user:*, group#member] or administrator from controller
define controller: [controller]
define reader: [user, user:*, group#member] or writer
define writer: [user, user:*, group#member] or administrator
define administrator: [user, user:*, group#member, role#assignee] or administrator from controller
define reader: [user, user:*, group#member, role#assignee] or writer
define writer: [user, user:*, group#member, role#assignee] or administrator

type serviceaccount
type applicationoffer
relations
define administrator: [user, user:*, group#member]

type user
define model: [model]
define administrator: [user, user:*, group#member, role#assignee] or administrator from model
define consumer: [user, user:*, group#member, role#assignee] or administrator
define reader: [user, user:*, group#member, role#assignee] or consumer

type role
relations
define assignee: [user, user:*, group#member]
type cloud
relations
define controller: [controller]
define administrator: [user, user:*, group#member, role#assignee] or administrator from controller
define can_addmodel: [user, user:*, group#member, role#assignee] or administrator

type group
type serviceaccount
relations
define member: [user, user:*, group#member]
define administrator: [user, user:*, group#member, role#assignee]

Loading

0 comments on commit 6738458

Please sign in to comment.