-
-
Notifications
You must be signed in to change notification settings - Fork 0
docs: 認可制御のドキュメントを整備 #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| ## 用語 | ||
|
|
||
| 表1: 可能な操作一覧 | ||
| - `Actor`: アクションを実行する主体.ほとんどの場合で`Account`が該当する. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actor の定義は網羅的にしておきたいです. 利用者のアカウントの他に, 特権的な管理者がある感じでしょうか?
There was a problem hiding this comment.
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`: リソースに対して行う何らかの操作のこと. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
行う操作の名称として, read や write などの形に限定しておいたほうが命名規則がぶれずに済みそうです.
| - Policy クラス は `isAllowed` static メソッドを持ち,actor, action, resource | ||
| の3値を要求する. | ||
| - `isAllowed` メソッドは `Option.Option<Error>` を返す. | ||
| - 要求が拒否された場合は `Option.Some<Error>` を返し,要求が承認された場合は | ||
| `Option.None()` を返す. |
There was a problem hiding this comment.
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;
}
// 特権的とは関係ない処理 ...
close #10
related: pulsate-dev/pulsate#1410