-
Hi Team, I need help in modelling a use case where permission condition changes based on the an attribute of the object. My requirement is, if I'm not able to figure out how to model
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Since OpenFGA uses relationships to determine authorization outcomes, every state of the authorization decision has to somehow be encoded in a Relationship Tuple that is stored in OpenFGA OR provided as a Contextual Tuple in the request (at request time). To model this scenario you could model the state of the
In your store you may have tuples such as
In your application you'll know at the time of a request if the project is in 'draft' or 'published' state. If it is in a 'draft' state then in your request you can do
If it is in a 'published' state then in your request you can do
The advantage of this approach is you don't have to update the tuples in OpenFGA every time a project's status is updated. Instead, pass that attribute status at the time the request is made. WDYT? |
Beta Was this translation helpful? Give feedback.
Since OpenFGA uses relationships to determine authorization outcomes, every state of the authorization decision has to somehow be encoded in a Relationship Tuple that is stored in OpenFGA OR provided as a Contextual Tuple in the request (at request time).
To model this scenario you could model the state of the
project
status as a relationship and then use that as a conditional guard in the relation definition forproject#can_delete
. For example,