You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to model an auth-model requirement where the authorization policy depends on the status of a resource. My requirement is similar to the one discussed here. In my case, whether a user has can_delete relation depends on whether the document is draft or published.
How could I model such an attribute check? I tried the solution discussed in the previous thread as follows but it does not seem to work unless I misunderstood the solution. Here is a sample that shows what I have tried.
type user
type group
relations
define member: [user]
type folder
relations
define owner: [user]
define admin: [group]
define draft_status: [folder]
define published_status: [folder]
define can_delete_draft: owner or member from admin
define can_delete_published: member from admin
define can_delete: (draft_status and can_delete_draft) or (published_status and can_delete_published)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I need to model an auth-model requirement where the authorization policy depends on the status of a resource. My requirement is similar to the one discussed here. In my case, whether a user has
can_delete
relation depends on whether the document is draft or published.How could I model such an attribute check? I tried the solution discussed in the previous thread as follows but it does not seem to work unless I misunderstood the solution. Here is a sample that shows what I have tried.
As you would see, I added the following relation
define draft_status: [folder]
and included the following contextual tuple in the query. But, the query returned Allowed=false. (See https://play.fga.dev/stores/create/?id=01JEQDW5BJKBX7260M96T43S20)
Changing the relation to the following works.
define draft_status: [user]
This is however definitely the wrong way to model this and can be confusing.
So, is there any way to check the existence of an attribute of a resource represented by a tuple?
Beta Was this translation helpful? Give feedback.
All reactions