-
Notifications
You must be signed in to change notification settings - Fork 17
feat: Add authorization models for vertical industries #70
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
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
fba5931
feat: added model for vertical industries
aaguiarz 1df2993
fix: simplified descriptions
aaguiarz 66102b7
feat: added more examples and addressed PR feedback
aaguiarz ec85a1e
fix: removed unnecessary relation
aaguiarz 26b3ba3
fix: bug in issue-tracking and fixed readme.mds
aaguiarz fd620d5
fix: more improvements based on feedback
aaguiarz c5cf1ae
fix: minor fixes across models
aaguiarz 408d5cb
fix: more model polishing
aaguiarz 52c248a
feat: added new models
aaguiarz 2ad8b35
chore: applied copiliot feedback
aaguiarz 13098c4
fix: refactor readme.md plus claude.md and copilot-instructions.md
aaguiarz a3c7c3d
fix: added list_objects and list_users tests to new models
aaguiarz 92dbc2f
fix: fixes in readme.md
aaguiarz b0bb66b
Update CLAUDE.md
aaguiarz 1abaecd
fix: broken internal link
aaguiarz 09ddd64
fix: address feedback
aaguiarz 6589895
Update stores/call-center/README.md
aaguiarz fe6272d
chore: improvement in ATS example
aaguiarz c1f6b82
Update stores/ecommerce/store.fga.yaml
aaguiarz 1f832db
fix: addressed PR feedback
aaguiarz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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,14 @@ | ||
| # OpenFGA Sample Stores | ||
|
|
||
| When working with OpenFGA models in this repository, install the OpenFGA skill: | ||
|
|
||
| ```sh | ||
| npx skills add openfga/agent-skills | ||
| ``` | ||
|
|
||
| Use `fga model test --tests store.fga.yaml` to validate models. | ||
|
|
||
| Run `fga model test --tests "stores/**/store.fga.yaml"` to test all models in the repository. | ||
|
|
||
|
|
||
|
|
This file contains hidden or 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
This file contains hidden or 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,11 @@ | ||
| { | ||
| "folders": [ | ||
| { | ||
| "path": "." | ||
| }, | ||
| { | ||
| "path": "../agent-skills" | ||
| } | ||
| ], | ||
| "settings": {} | ||
| } |
This file contains hidden or 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,25 @@ | ||
| # OpenFGA for Accounting Systems | ||
|
|
||
| ## Use Case | ||
|
|
||
| This model represents the authorization needs of an **accounting platform**, like QuickBooks Online, Xero, or FreshBooks. These platforms manage charts of accounts, invoices, expenses, payments, journal entries, and financial statements. | ||
|
|
||
| The model captures the following requirements: | ||
|
|
||
| - **Multi-tenancy**: Multiple organizations, each with their own chart of accounts, contacts, and financial records. | ||
| - **Parent-scoped creation permissions**: Account and payment creation are checked on the organization (`can_create_account`, `can_create_payment`) rather than on account or payment objects that do not exist yet. | ||
| - **Separation of duties**: Three distinct roles — `admin` (full control + approvals), `accountant` (day-to-day bookkeeping), and `auditor` (read-only access to all financial data). Regular members have no access to accounting data. | ||
| - **Read-only audit access**: Auditors can view all financial data (accounts, invoices, expenses, payments, journal entries, financial statements) but cannot modify anything, supporting compliance and external audit requirements. | ||
| - **Expense workflow**: Employees submit expenses they can view and edit; accountants and admins can approve them. | ||
| - **Purchase order approval chain**: Requesters create and edit purchase orders, designated approvers authorize them, and admins have override approval authority. | ||
| - **Journal entry posting**: Accountants can create and edit journal entries, but only admins can post them to the general ledger, preventing unauthorized modifications to the books. | ||
| - **Invoice lifecycle**: Creators can manage their invoices, but voiding requires admin authority. | ||
| - **Financial statement protection**: Balance sheets, income statements, and cash flow statements are read-only resources accessible only to accountants, admins, and auditors. | ||
|
|
||
| The model, tuples, and tests are in [model.fga](./model.fga) and [store.fga.yaml](./store.fga.yaml). | ||
|
|
||
| ## Try It Out | ||
|
|
||
| 1. Make sure you have the [FGA CLI](https://github.com/openfga/cli/?tab=readme-ov-file#installation) | ||
|
|
||
| 2. In the `accounting` directory, run `fga model test --tests store.fga.yaml` |
This file contains hidden or 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,73 @@ | ||
| model | ||
| schema 1.1 | ||
|
|
||
| type user | ||
|
|
||
| type organization | ||
| relations | ||
| define admin: [user] | ||
| define accountant: [user] or admin | ||
| define auditor: [user] or accountant | ||
| define member: [user] or auditor | ||
| define can_create_account: accountant | ||
| define can_create_payment: accountant | ||
|
|
||
| type account | ||
| relations | ||
| define organization: [organization] | ||
| define can_edit: accountant from organization | ||
| define can_view: auditor from organization or can_edit | ||
|
|
||
| type contact | ||
| relations | ||
| define organization: [organization] | ||
| define owner: [user] | ||
| define can_edit: owner or accountant from organization | ||
| define can_view: can_edit | ||
|
|
||
| type invoice | ||
| relations | ||
| define organization: [organization] | ||
| define creator: [user] | ||
| define contact: [contact] | ||
| define can_void: admin from organization | ||
| define can_approve: can_void | ||
| define can_edit: creator or accountant from organization or can_approve | ||
| define can_view: owner from contact or auditor from organization or can_edit | ||
|
|
||
| type expense | ||
| relations | ||
| define organization: [organization] | ||
| define submitter: [user] | ||
| define can_approve: accountant from organization | ||
| define can_edit: submitter or can_approve | ||
| define can_view: auditor from organization or can_edit | ||
|
|
||
| type payment | ||
| relations | ||
| define organization: [organization] | ||
| define can_edit: accountant from organization | ||
| define can_view: auditor from organization or can_edit | ||
|
|
||
| type journal_entry | ||
| relations | ||
| define organization: [organization] | ||
| define creator: [user] | ||
| define can_post: admin from organization | ||
| define can_edit: creator or accountant from organization or can_post | ||
| define can_view: auditor from organization or can_edit | ||
|
|
||
| type purchase_order | ||
| relations | ||
| define organization: [organization] | ||
| define requester: [user] | ||
| define approver: [user] | ||
| define can_approve: approver or admin from organization | ||
| define can_edit: requester or can_approve or accountant from organization | ||
| define can_view: can_edit | ||
|
|
||
| type financial_statement | ||
| relations | ||
| define organization: [organization] | ||
| define can_edit: admin from organization | ||
| define can_view: auditor from organization or can_edit |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.