Skip to content
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

Allow using computed fields in row-level permissions #5646

Closed
amille14 opened this issue Aug 22, 2020 · 2 comments
Closed

Allow using computed fields in row-level permissions #5646

amille14 opened this issue Aug 22, 2020 · 2 comments
Assignees
Labels
a/authz Issues related to "authorization" and the policy engine after session claims are procesed k/enhancement New feature or improve an existing feature

Comments

@amille14
Copy link

It would be really helpful to be able to use computed fields where the only argument is the current table row in row level permissions. Currently, computed fields don't appear in the list.

This would allow you to set up something like select permissions on a user where full_name equals "Bob" or whatever, assuming full_name is a computed field that uses only the current user row as input and just combines the row's first_name and last_name fields.

In a more real example, this is particularly useful because it allows you to encapsulate complex permission logic into a single, reusable function, rather than being forced to manually add it through the console's permission ui which can get very tedious and difficult to test, especially in cases where you're repeating the same chunk of permissions across multiple roles and actions with only slight variations.

@altschuler
Copy link

altschuler commented Dec 12, 2020

Edit: my mistake, I can just use expiry: { _gt: "now()" } in the permission, there was an unrelated issue. However I'll leave the below as I guess it still stands in a case where a simple solution like that would not be possible.

My use-case for this: I have an expiry field (a date) in a table called things, and I need to only allow selecting rows where expiry is in the future. I would then create a computed field called is_expired which returns a boolean indicating whether expiry is in the future, and would like to use that field in a permission config.

@vaishnavigvs vaishnavigvs added the a/authz Issues related to "authorization" and the policy engine after session claims are procesed label Jun 25, 2021
@0x777
Copy link
Member

0x777 commented Oct 7, 2021

This has been added in v2.0.4.

@0x777 0x777 closed this as completed Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a/authz Issues related to "authorization" and the policy engine after session claims are procesed k/enhancement New feature or improve an existing feature
Projects
None yet
Development

No branches or pull requests

5 participants