Skip to content

[Feature Request] Field-level policy: provide a way to "override" model-level rules #809

Closed
@ymc9

Description

@ymc9

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:

  • Admin users can update all fields of "User" model
  • Regular users can only update "password" field of their own

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions