[Feature Request] .check method for v3
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 15/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- typescript
- Lĩnh vực
- authorization
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 2.9k
- Fork
- 157
- Merge trung bình
- 2 ngày 46 phút
- Pull request đã merge (30 ngày)
- 17
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của zenstackhq/zenstack
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
zenstackhq/zenstack#2873 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`@default` on a field of a `@map`-ed enum emits the enum name as the column defaultCó thể đã có người làm @jkugsiya đã nhận 4 ngày trước. Đang mởruntime
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
zenstackhq/zenstack#2868 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
zenstackhq/zenstack#2694 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
zenstackhq/zenstack#2659 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
zenstackhq/zenstack#2542 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của zenstackhq/zenstack
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
TomerAberbach/profiler-md#733 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug priority: medium
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
brentspine/brents-toasts#143 ·
-
🐛 bug 🗺️ DB Models & Ops
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
LibreChat-AI/LibreChat#17214 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
Wavvon/Wavvon-clients#136 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
umami-software/umami#4637 ·
Maintainer thường phản hồi trong vòng 3 ngày