-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add modular models example (#22)
* chore: add modular models example * Update stores/modular/fga.mod Co-authored-by: Raghd Hamzeh <[email protected]> --------- Co-authored-by: Raghd Hamzeh <[email protected]>
- Loading branch information
1 parent
03a392d
commit e9afab0
Showing
7 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# OpenFGA Modular Model Sample Store | ||
|
||
* **Title**: **Modular Model** | ||
|
||
## Use-Case | ||
|
||
This example showcases how to use modular models to separate your model across multiple files and how to use type extensions within those modules. | ||
|
||
## Try It Out | ||
|
||
1. Make sure you have the [FGA CLI](https://github.com/openfga/cli/?tab=readme-ov-file#installation) | ||
|
||
2. In the `modular` directory, run `fga model test --tests store.fga.yaml` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module core | ||
|
||
type user | ||
|
||
type organization | ||
relations | ||
define member: [user] or admin | ||
define admin: [user] | ||
|
||
type group | ||
relations | ||
define member: [user] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
schema: '1.2' | ||
contents: | ||
- core.fga | ||
- issue-tracker/projects.fga | ||
- issue-tracker/tickets.fga | ||
- wiki.fga |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module issue-tracker | ||
|
||
extend type organization | ||
relations | ||
define can_create_project: admin | ||
|
||
type project | ||
relations | ||
define organization: [organization] | ||
define viewer: member from organization |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module issue-tracker | ||
|
||
type ticket | ||
relations | ||
define project: [project] | ||
define owner: [user] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: ModularDemo | ||
model_file: ./fga.mod | ||
tuples: | ||
- user: user:anne | ||
relation: admin | ||
object: organization:openfga | ||
- user: organization:openfga | ||
relation: organization | ||
object: space:openfga | ||
- user: organization:openfga | ||
relation: organization | ||
object: project:openfga | ||
tests: | ||
- name: Members can view projects | ||
check: | ||
- user: user:anne | ||
object: organization:openfga | ||
assertions: | ||
admin: true | ||
member: true | ||
can_create_space: true | ||
- user: user:anne | ||
object: space:openfga | ||
assertions: | ||
can_view_pages: true | ||
- user: user:anne | ||
object: project:openfga | ||
assertions: | ||
viewer: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module wiki | ||
|
||
extend type organization | ||
relations | ||
define can_create_space: admin | ||
|
||
|
||
type space | ||
relations | ||
define organization: [organization] | ||
define can_view_pages: member from organization | ||
|
||
type page | ||
relations | ||
define space: [space] | ||
define owner: [user] |