-
-
Notifications
You must be signed in to change notification settings - Fork 91
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
[Feature Request] Field-level policy: provide a way to "override" model-level rules #809
Comments
Hi @jasonmacdonald , you also mentioned another case:
Could you show the Prisma query that you want to make work? I just want to make sure it's also covered in the implementation. Thanks! |
Really, it's the same as the first, only on a relation rather than a property. Example: model User {
id String @id @unique @default(uuid()) @db.Uuid
...
password String @allow('update', auth() == this, true)
profileId String @unique
profile Profile @relation(fields: [profileId], references: [id]) @allow('update', auth() == this, true)
@@allow('create,update,delete', auth().role == 'ADMIN')
@@allow('read', true)
} In this scenario, you could not update the password or anything in the Profile, even though you may have permission to update your own profile since the model level If, however, both
I would assume the ability to resolve the first scenario would likely work for the second, so it might just be a matter of ensuring it works. |
Got it. Thanks for providing the details. I'm actually thinking, if only "profile" is updated, it probably shouldn't trigger |
Yes, when no |
Today, for having access to a field, both model-level and field-level (if any) policies need to be satisfied. This can be very inconvenient for scenarios where a user can only update one field but nothing else.
Concrete example:
To allow the second rule, we have to let regular users pass model-level "update" policies, however, then we have to add "@deny" rule on all fields except for "password".
The proposed solution, as discussed with @jasonmacdonald , is to introduce a third parameter to "@Allow" attribute to let it "override" model-level policies:
password String @allow('update', auth() == this, true)
Discord thread: https://discord.com/channels/1035538056146595961/1171196847797325854
The text was updated successfully, but these errors were encountered: