Sure, here's an example OpenFGA authorization model for fine-grained authorization on joint accounts for customers:
openfga:
authorize:
model-definition:
version: '1.0'
name: 'JointAccountAuthorizationModel'
description: 'Authorization model for joint accounts'
resources:
- '/joint-accounts/*'
providers:
- 'catalog-provider'
- 'identity-provider'
subjects:
- 'customers'
actions:
- 'list-joint-accounts'
- 'create-joint-account'
- 'modify-joint-account'
- 'delete-joint-account'
- 'list- joint-account-users'
- 'add-joint-account-user'
- 'remove-joint-account-user'
resources-subjects:
- '/joint-accounts/*'
.with-providers(['catalog-provider', 'identity-provider'])
.with-subjects(['customers'])
policy-definitions:
- 'read-joint-accounts':
description: 'Read joint account information'
actions: ['list-joint-accounts']
resources: ['/joint-accounts/*']
providers: ['catalog-provider']
subjects: ['customers']
- 'create-joint-account':
description: 'Create a joint account'
actions: ['create-joint-account']
resources: ['/joint-accounts']
providers: ['catalog-provider']
subjects: ['customers']
- 'modify-joint-account':
description: 'Modify an existing joint account'
actions: ['modify-joint-account']
resources: ['/joint-accounts/*']
providers: ['catalog-provider']
subjects: ['customers']
- 'delete-joint-account':
description: 'Delete a joint account'
actions: ['delete-joint-account']
resources: ['/joint-accounts/*']
providers: ['catalog-provider']
subjects: ['customers']
- 'list-joint-account-users':
description: 'List users associated with a joint account'
actions: ['list-joint-account-users']
resources: ['/joint-accounts/*']
providers: ['catalog-provider']
subjects: ['customers']
- 'add-joint-account-user':
description: 'Add a user to a joint account'
actions: ['add-joint-account-user']
resources: ['/joint-accounts/*']
providers: ['catalog-provider']
subjects: ['customers']
- 'remove-joint-account-user':
description: 'Remove a user from a joint account'
actions: ['remove-joint-account-user']
resources: ['/joint-accounts/*']
providers: ['catalog-provider']
subjects: ['customers']
In this model, we define a JointAccountAuthorizationModel with a version of 1.0. The model specifies the resources that can be accessed by joint accounts, including a list of /joint-accounts/* resources.
The model also specifies the providers that can be used to authorize access to these resources, including catalog-provider and identity-provider. We define a list of subjects that can access these resources, which includes customers.
The model then defines a set of actions that can be performed on these resources, including creating, modifying, deleting, and listing joint accounts, as well as listing and adding/removing users from joint accounts.
Finally, the model defines a set of policy definitions that specify the allowed actions for each of these actions. These policy definitions include the read-joint-accounts, create-joint-account, modify-joint-account, delete-joint-account, list-joint-account-users, add-joint-account-user, and remove-joint-account-user actions.
With these definitions, an OpenFGA authorization server can enforce fine-grained authorization