Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[Feature Request] .check method for v3

オープン
#2,339 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
15/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
typescript
領域
authorization

調査の方向性

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
平均マージ
2日 46分
マージ済み PR(30日)
17

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

zenstackhq/zenstack のほかの issue

zenstackhq/zenstack の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。