Restrict mutation input when inserting/updating entries #8808
Unanswered
rkeulemans
asked this question in
Question
Replies: 1 comment
-
You can use role-based access control, to restrict users to only insert/update their own records. https://hasura.io/docs/latest/auth/authorization/roles-variables/ |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Scenario
Say we have a database with four entities,
Company
,User
,UserCompany
(linking table betweenUser
andCompany
),Group
(which has anid
,company_id
(foreign key) and aname
) and finally aUserGroup
(linking table betweenUser
andGroup
). Now we expose this database using Hasura.Questions
insert_user_group_one(..)
mutation, onlyid
s of users can be inserted that are actually in theCompany
that the user that tries to insert this belongs to? If we use Postgres triggers, how can we access theid
of the user executing the mutation? Preferably we don't use Postgres triggers, since then we are implementing authentication in two places (in Hasura itself and on database level).company_id
equal to the company he is in?Beta Was this translation helpful? Give feedback.
All reactions