Comments (1)
Hi @bvkimball , thank you for filing this FR with a great explanation! If I'm understanding it correctly, the proposal covers two aspects:
- A way of passing extra variables to policy rules at runtime
- A way of conditionally enabling/disabling some rules (on multiple models)
# 1 is similar to #1402. We can probably start by allowing the args()
construct at the client level and then extend it to the query level for better flexibility. The latter will involve extending PrismaClient
's current TS interface, but we're already doing it in V2 anyway 😄.
# 2 may be related to another thing that I've been thinking about for a while. Let me try to explain it here.
The current way policies are modeled in ZenStack is probably not good enough for modeling applications with multiple "sides". For example, an EC app can have a storefront "side" and a fulfillment "side". Authoring their rather different authorization rules in a "flat" way can be quite cumbersome and hard to maintain. So maybe we should introduce something like "profile" to segregate different sets of rules. (Please ignore the syntax, as it's just for showing the idea).
model Order {
...
@@profile('storefront', [
allow('read', ...),
deny('update', ...)
])
@@profile('fulfillment', [
allow('read', ...),
deny('update', ...)
])
}
So at enhancement time we can do:
const storefrontDb = enhance(prisma, ..., { profiles: ['storefront'] });
We can also allow overriding profiles at query time.
Back to your proposal, the equivalent will probably be something like:
model Post {
//...
effectiveStart DateTime
effectiveEnd DateTime
comments Comment[]
@@profile('asOf', [
deny('read', !(effectiveStart < args().timestamp && (effectiveEnd > args().timestamp || effectiveEnd == null))))
])
}
await db.post.findMany({
select: {
title: true,
comments: {
select: {
id: true,
message: true,
},
},
},
profiles: [ 'asOf' ],
args: { timestamp: '2024-12-24' }
});
I'm still not really sure to what extent this really overlaps with your original thoughts, but just wanted to throw out some wild ideas 😄.
from zenstack.
Related Issues (20)
- [Feature Request] A general-purposed context object for injecting values into access policy rules at runtime
- When using upsert the @default(auth().field) is not been handled HOT 2
- 'unsetMarker' resolves to a type-only declaration and must be imported using a type-only import HOT 5
- Cannot read properties of undefined (reading 'aggregate') HOT 4
- Cannot select where on fields from base model when using inheritance HOT 2
- Generated code can't compile when schema contains delegate models without concrete models HOT 1
- Generation error when a delegate model has relation to another delegate model HOT 1
- [Doc] Update Clerk guide to Next.js app router
- [Doc] Update Auth.js guide to Next.js app router
- [BUG] Query Discrepancy with Selected Relation Fields HOT 2
- [Language Server] No autocompletion is provided when accessing `auth().`
- input error when querying compound key entry HOT 2
- [BUG] Types generated when using `@default(auth().id)` are not compatible with third party libraryes HOT 2
- [Feature Request] TRPC plugin should generate router procedure for permission checker
- Error - Maximum call stack size exceeded HOT 6
- Policy filtering should respect field-level access policies
- [Feature Request] Reuse primitive types with validation rules
- [Feature Request] Compatibility with Prisma 5.14 `createManyAndReturn`
- [Feature Request] Hono Support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zenstack.