zenstackhq / zenstack

Fullstack TypeScript toolkit that enhances Prisma ORM with flexible Authorization layer for RBAC/ABAC/PBAC/ReBAC, offering auto-generated type-safe APIs and frontend hooks.
https://zenstack.dev
MIT License
2.07k stars 88 forks source link

"now()" function in Access Policies #478

Closed rickserraglia closed 1 year ago

rickserraglia commented 1 year ago

Before any requests, I would just like to thank you for the work you've done, we are in love with your solutions, it's been amazing to work with ZenStack on our stack.

This week we were wondering about the possibility of including date validation in access policies, which was something that Supabase offered us, and we didn't find it in ZenStack (but seriously, we managed to survive without it, your solution is by far the best for us even without it).

It's a function that would compare the timestamp of some date column with the current time. And that it was possible to create comparisons (<, >, <=, >=, =, ==).

How it works in Supabase RLS: ((now() >= starts_at) AND (now() <= ends_at))

How could be in ZenStack Access Policy: @@allow('read', startsAt <= now() && endsAt >= now())

ymc9 commented 1 year ago

Thanks @rickserraglia . Yes, this will be a very useful addition!

ymc9 commented 1 year ago

Hi @rickserraglia, it's supported in the latest "beta.1" release now!

rickserraglia commented 1 year ago

Hi @rickserraglia, it's supported in the latest "beta.1" release now!

Wowww! That's awesome! 🔥🚀