Skip to content

Conversation

@laminne
Copy link
Member

@laminne laminne commented Jan 29, 2026

close #10

related: pulsate-dev/pulsate#1410

@laminne laminne self-assigned this Jan 29, 2026
@laminne laminne marked this pull request as ready for review January 30, 2026 12:56
@laminne laminne enabled auto-merge January 30, 2026 12:56
@laminne laminne requested a review from MikuroXina January 30, 2026 12:56
## 用語

表1: 可能な操作一覧
- `Actor`: アクションを実行する主体.ほとんどの場合で`Account`が該当する.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actor の定義は網羅的にしておきたいです. 利用者のアカウントの他に, 特権的な管理者がある感じでしょうか?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cli等から起動できる管理系タスクが実装される可能性があるかなと思ってこう書いていますが,現時点では予定がないのでAccountのみにしておきます


表1: 可能な操作一覧
- `Actor`: アクションを実行する主体.ほとんどの場合で`Account`が該当する.
- `Action`: リソースに対して行う何らかの操作のこと.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

行う操作の名称として, readwrite などの形に限定しておいたほうが命名規則がぶれずに済みそうです.

Comment on lines +15 to +19
- Policy クラス は `isAllowed` static メソッドを持ち,actor, action, resource
の3値を要求する.
- `isAllowed` メソッドは `Option.Option<Error>` を返す.
- 要求が拒否された場合は `Option.Some<Error>` を返し,要求が承認された場合は
`Option.None()` を返す.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

引数と戻り値の形から, isAllowed というメソッド名は boolean を返しそうに見えて違和感を覚えます. また, 結局のところそのチェックと実際の操作が分離してしまうので少しもったいないと感じます.
以下のように, Policy クラスはコンストラクタに操作対象, actor, action, resource を受け取るようにして, withCheck を介することでチェック付きの操作ができるようにしてみてはどうでしょうか.

const policy = new Policy(target, actor, action, resource);

const result = policy.withCheck((target) => {
  // 特権的な処理の実行
  const res = target.privilegeAction(/* ... */);
  if (Result.isErr(res)) {
    return res;
  }
  const foo = Result.unwrap(res);
  // 特権的な処理の結果の利用 ...
  return Result.ok(/* ... */);
});

if (Result.isErr(res)) {
  return res;
}
// 特権的とは関係ない処理 ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: アクセス制御/権限に関するドキュメントを追加する

3 participants