-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026 Shota FUJI
//
// This program is free software: you can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
// PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License along
// with this program. If not, see <http://www.gnu.org/licenses/>.
namespace Yamori.Auth.V1;
/// リソースに対するアクセスの種類
enum ResourceAccessType : uint8 {
/// 上書きや削除といった既存のデータに対する変更
Modify,
/// 追加・登録
///
/// 既存の同種リソースに対して変更は発生しない。同種の他のリソースに対して
/// 変更が必要な場合は `Modify` のリソース変更も同時に認可を行う。
Create,
/// 読み取り
///
/// 一覧取得といったアクセスは個別のリソースに対してそれぞれ `Read` の
/// 認可が行われる。
Read,
}
/// ワークスペース固有のカスタム属性定義
///
/// この定義を基に各ユーザにカスタム属性が定義できる。表示名の変更や半角・全角問題
/// などに対応するため、自由入力はできず事前に定義された選択肢の中から選ぶ。
///
/// また「ユーザ情報変更はできるが一部のカスタム属性にアクセスできない」といった
/// ケースを考慮し、全てのカスタム属性は任意選択とする。
table UserAttributeDefinition {
/// ユーザ・組織が設定する、認可や一意性確保のための識別キー
///
/// ユーザによって値が変更される場合がある。
key: string (required);
}
/// ユーザに設定されたカスタム属性
table UserAttribute {
/// 該当する `UserAttributeDefinition` の `key`
definition_key: string (required);
/// 選択肢のキー
choice_key: string;
}
/// システムに登録されているログイン可能なユーザ
table User {
/// システムによって自動発番された ID
///
/// 同一判定にはこのフィールドを利用すること。値は不変である。
id: string (required);
/// 管理者かどうか
///
/// `attributes` でも表現できる属性ではあるが、ベクターを毎回走査するパフォーマンス
/// ペナルティを避けるために設置している。ハンドラ内でまずこのフィールドを確認し、
/// `true` の場合にアクセスを許可すれば「誰もアクセスできないデータがある」状態を
/// 避けることができる。
///
/// サーバにあるデータベースファイルにアクセスできる人物は実質全てのアクセス権限を
/// 持つに等しい。ただ、意図しない変更を予防する等の理由でアクセスを制限することにも
/// 長所があるため、組織のリスクマネジメント方針に基づいて決めることを推奨。
is_super_user: bool;
/// ワークスペース固有のカスタム属性一覧
attributes: [UserAttribute];
}
union Resource {
User,
UserAttribute,
UserAttributeDefinition,
}
/// 認可用 WebAssembly 関数に渡されるデータ
table AccessRequest {
/// アクセスを要求しているユーザ
user: User (required);
/// アクセスの種類
access_type: ResourceAccessType;
/// アクセスしようとしているリソース
resource: Resource;
}
root_type AccessRequest;