[Feature Request] .check method for v3
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 15/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- typescript
调研方向
Start from the v2 check-permission guide (zenstack.dev/docs/2.x/guides/check-permission) to see how the removed .check API worked, then compare with the current v3 enhanced-client entry points and the policy-writing docs at zenstack.dev/docs/orm/access-control/write-policies. The proposal is an isAllowedTo('create' | 'update', ...) style call on the auth-scoped client, covering both model-level and row-level checks. Note v3 permission handling changed, so an equivalent design (or a decision to keep it removed) needs maintainer input before any test surface is chosen; none is defined here yet.
由索引模型根据 Issue 内容生成。
描述
Turns out it was implemented in v2 the .check method
https://zenstack.dev/docs/2.x/guides/check-permission
Is your feature request related to a problem? Please describe.
Yes my schema defines permissions per row, some rows are editable, deleteable etc by a certain user, only my frontend is not aware of this. Currenly im mimicking my policies in some sort of permission layer to figure out if i need to show or hide a edit button in my admin area.
Describe the solution you'd like
I would like to have a similar solution as in Ruby's best authorisation plugin CanCanCan as explained here: https://github.com/CanCanCommunity/cancancan/blob/develop/docs/define_check_abilities.md
# check if a user is allowed to create a model (name is Article)
can? :create, Article, user: user
# or update a specific articel instance
@article = Article.find(params[:id])
can? :update, @article, user: user
Lets switch back to zensteack, i would like something like this, lets take the user policy
taken from https://zenstack.dev/docs/orm/access-control/write-policies
model User {
id Int @id @default(autoincrement())
email String @unique
posts Post[]
// open to signup, profiles are public
@@allow('create,read', true)
// the user himself has full access
@@allow('all', auth().id == id)
}
This could be a solution?
const userDb = authDb.$setAuth(user);
// something like this? to see if a policiy is applicable, so that i could show a [create] button or whatever
userDb.user.isAllowedTo('create')
// than for a row based
userDb.user.findUnique({where: {id: auth().id}}).isAllowedTo('update')
Im searching for this isAllowedTo or in CanCanCan the can? method.
Describe alternatives you've considered
No ive got my Ai going over all my policies and it writes a permission.ts and this a horrible developmentflow.
- 主要语言
- TypeScript
- 星标
- 2.9k
- 派生
- 157
- 平均合并
- 4 天 5 小时
- 30 天内合并 PR
- 22
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
zenstackhq/zenstack 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 68/100
zenstackhq/zenstack#2873 ·
维护者通常 1 天内回复
-
`@default` on a field of a `@map`-ed enum emits the enum name as the column default可能重新可做 @jkugsiya 于 12 天前认领,目前没有进行中的 PR。 未关闭runtime
难度 2/5 1-3 小时 新手友好度 78/100
zenstackhq/zenstack#2868 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
zenstackhq/zenstack#2694 · 3 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 68/100
zenstackhq/zenstack#2659 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
zenstackhq/zenstack#2542 · 1 条评论 ·
维护者通常 1 天内回复
查看 zenstackhq/zenstack 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 66/100
pingdotgg/t3code#24900 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
inu-appcenter/UNIDorm-web#411 ·
维护者通常 1 天内回复
-
🐛 bug
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
ranxianglei/billion-context#4720 ·
维护者通常 1 天内回复
-
area:arcade game p3-medium ready-for-agent type:bug
难度 2/5 1-3 小时 新手友好度 82/100
fderuiter/deruiter.dev#2840 ·
维护者通常 1 天内回复