yamori

有給休暇計算を主目的とした簡易勤怠管理システム

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 70
  71. 71
  72. 72
  73. 73
  74. 74
  75. 75
  76. 76
  77. 77
  78. 78
  79. 79
  80. 80
  81. 81
  82. 82
  83. 83
  84. 84
  85. 85
  86. 86
  87. 87
  88. 88
  89. 89
  90. 90
  91. 91
  92. 92
  93. 93
  94. 94
  95. 95
  96. 96
  97. 97
  98. 98
  99. 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;