ABAC(属性ベースアクセス制御)
概要
ABAC(Attribute-Based Access Control)APIは、ユーザーの属性を管理し、属性に基づいたアクセス制御を実装するためのエンドポイントを提供します。年齢、部門、資格、認証レベルなどの属性を設定し、ポリシーと組み合わせて柔軟なアクセス制御が可能です。
エンドポイント一覧
| メソッド | エンドポイント | 説明 |
|---|---|---|
| GET | /api/admin/attributes | 属性定義一覧取得 |
| POST | /api/admin/attributes | 属性定義作成 |
| GET | /api/admin/attributes/users/:userId | ユーザー属性取得 |
| PUT | /api/admin/attributes/users/:userId | ユーザー属性更新 |
| DELETE | /api/admin/attributes/users/:userId/:key | ユーザー属性削除 |
| GET | /api/admin/attributes/verifications | 検証履歴一覧取得 |
| POST | /api/admin/attributes/verifications | 属性検証実行 |
| GET | /api/admin/attributes/stats | 属性統計取得 |
| POST | /api/admin/attributes/bulk/cleanup-expired | 期限切れ属性の一括削除 |
属性定義一覧取得
テナントで定義されている属性の一覧を取得します。
エンドポイント
GET /api/admin/attributes
クエリパラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
limit | integer | - | 取得件数(デフォルト: 50) |
cursor | string | - | ページネーションカーソル |
category | string | - | カテゴリでフィルタ |
リクエスト例
curl -X GET "https://{tenant-domain}/api/admin/attributes" \ -H "Authorization: Bearer {token}"レスポンス例
{ "items": [ { "key": "age_verified", "display_name": "年齢確認済み", "description": "ユーザーの年齢確認状態", "type": "boolean", "category": "verification", "required": false, "default_value": false, "created_at": 1705881600 }, { "key": "department", "display_name": "部門", "description": "所属部門", "type": "string", "category": "organization", "required": true, "allowed_values": ["Engineering", "Sales", "Marketing", "HR"], "created_at": 1705968000 }, { "key": "clearance_level", "display_name": "セキュリティクリアランス", "description": "セキュリティクリアランスレベル", "type": "integer", "category": "security", "required": false, "min_value": 1, "max_value": 5, "default_value": 1, "created_at": 1706054400 } ], "total": 15}属性定義作成
新しい属性定義を作成します。
エンドポイント
POST /api/admin/attributes
リクエストボディ
| フィールド | 型 | 必須 | 説明 |
|---|---|---|---|
key | string | ○ | 属性キー(英数字、アンダースコア) |
display_name | string | ○ | 表示名 |
description | string | - | 説明 |
type | string | ○ | 型(string, integer, boolean, date, array) |
category | string | - | カテゴリ |
required | boolean | - | 必須かどうか |
default_value | any | - | デフォルト値 |
allowed_values | array | - | 許可される値(列挙型の場合) |
min_value | number | - | 最小値(数値型の場合) |
max_value | number | - | 最大値(数値型の場合) |
expires_after | integer | - | 有効期限(秒) |
リクエスト例
curl -X POST "https://{tenant-domain}/api/admin/attributes" \ -H "Authorization: Bearer {token}" \ -H "Content-Type: application/json" \ -d '{ "key": "certification", "display_name": "資格", "description": "取得している資格", "type": "array", "category": "qualification", "required": false, "allowed_values": ["AWS-SAA", "AWS-SAP", "GCP-ACE", "GCP-PCA"] }'レスポンス例
{ "key": "certification", "display_name": "資格", "type": "array", "category": "qualification", "created_at": 1706140800}ユーザー属性取得
指定されたユーザーの属性を取得します。
エンドポイント
GET /api/admin/attributes/users/:userId
パスパラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
userId | string | ○ | ユーザーID |
リクエスト例
curl -X GET "https://{tenant-domain}/api/admin/attributes/users/usr_abc123" \ -H "Authorization: Bearer {token}"レスポンス例
{ "user_id": "usr_abc123", "attributes": { "age_verified": { "value": true, "verified_at": 1705881600, "verified_by": "system", "expires_at": null }, "department": { "value": "Engineering", "set_at": 1705968000, "set_by": "usr_admin001" }, "clearance_level": { "value": 3, "set_at": 1706054400, "set_by": "usr_admin001", "expires_at": 1737590400 }, "certification": { "value": ["AWS-SAA", "GCP-ACE"], "set_at": 1706140800, "set_by": "usr_admin001" } }}ユーザー属性更新
ユーザーの属性を更新します。
エンドポイント
PUT /api/admin/attributes/users/:userId
パスパラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
userId | string | ○ | ユーザーID |
リクエストボディ
| フィールド | 型 | 必須 | 説明 |
|---|---|---|---|
attributes | object | ○ | 属性のキーと値のマップ |
リクエスト例
curl -X PUT "https://{tenant-domain}/api/admin/attributes/users/usr_abc123" \ -H "Authorization: Bearer {token}" \ -H "Content-Type: application/json" \ -d '{ "attributes": { "clearance_level": 4, "certification": ["AWS-SAA", "AWS-SAP", "GCP-ACE"] } }'レスポンス例
{ "user_id": "usr_abc123", "updated_attributes": ["clearance_level", "certification"], "updated_at": 1706227200}ユーザー属性削除
ユーザーから特定の属性を削除します。
エンドポイント
DELETE /api/admin/attributes/users/:userId/:key
パスパラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
userId | string | ○ | ユーザーID |
key | string | ○ | 属性キー |
リクエスト例
curl -X DELETE "https://{tenant-domain}/api/admin/attributes/users/usr_abc123/certification" \ -H "Authorization: Bearer {token}"レスポンス
ステータスコード 204 No Content(ボディなし)
検証履歴一覧取得
属性検証の履歴を取得します。
エンドポイント
GET /api/admin/attributes/verifications
クエリパラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
limit | integer | - | 取得件数(デフォルト: 50) |
cursor | string | - | ページネーションカーソル |
user_id | string | - | ユーザーIDでフィルタ |
attribute_key | string | - | 属性キーでフィルタ |
result | string | - | 結果でフィルタ(verified, rejected, pending) |
リクエスト例
curl -X GET "https://{tenant-domain}/api/admin/attributes/verifications?attribute_key=age_verified" \ -H "Authorization: Bearer {token}"レスポンス例
{ "items": [ { "id": "ver_abc123", "user_id": "usr_xyz789", "attribute_key": "age_verified", "result": "verified", "method": "document_upload", "verified_by": "system", "verified_at": 1706140800, "evidence": { "document_type": "drivers_license", "document_id": "doc_xxx" } } ], "total": 50, "cursor": "eyJpZCI6InZlcl9hYmMxMjMifQ=="}属性検証実行
管理者が属性を手動で検証します。
エンドポイント
POST /api/admin/attributes/verifications
リクエストボディ
| フィールド | 型 | 必須 | 説明 |
|---|---|---|---|
user_id | string | ○ | ユーザーID |
attribute_key | string | ○ | 属性キー |
value | any | ○ | 検証する値 |
result | string | ○ | 結果(verified, rejected) |
notes | string | - | 備考 |
リクエスト例
curl -X POST "https://{tenant-domain}/api/admin/attributes/verifications" \ -H "Authorization: Bearer {token}" \ -H "Content-Type: application/json" \ -d '{ "user_id": "usr_abc123", "attribute_key": "age_verified", "value": true, "result": "verified", "notes": "本人確認書類を確認" }'レスポンス例
{ "id": "ver_new789", "user_id": "usr_abc123", "attribute_key": "age_verified", "result": "verified", "verified_by": "usr_admin001", "verified_at": 1706313600}属性統計取得
属性の使用状況に関する統計を取得します。
エンドポイント
GET /api/admin/attributes/stats
リクエスト例
curl -X GET "https://{tenant-domain}/api/admin/attributes/stats" \ -H "Authorization: Bearer {token}"レスポンス例
{ "total_users_with_attributes": 1250, "attributes": { "age_verified": { "users_count": 800, "verified_count": 750, "pending_count": 50 }, "department": { "users_count": 1200, "distribution": { "Engineering": 450, "Sales": 300, "Marketing": 250, "HR": 200 } }, "clearance_level": { "users_count": 500, "distribution": { "1": 200, "2": 150, "3": 100, "4": 40, "5": 10 } } }, "expiring_soon": 25}期限切れ属性の一括削除
有効期限が切れた属性を一括で削除します。
エンドポイント
POST /api/admin/attributes/bulk/cleanup-expired
リクエストボディ
| フィールド | 型 | 必須 | 説明 |
|---|---|---|---|
attribute_keys | string[] | - | 対象の属性キー(指定しない場合は全て) |
dry_run | boolean | - | ドライラン(実際には削除しない) |
リクエスト例
curl -X POST "https://{tenant-domain}/api/admin/attributes/bulk/cleanup-expired" \ -H "Authorization: Bearer {token}" \ -H "Content-Type: application/json" \ -d '{ "attribute_keys": ["clearance_level"], "dry_run": true }'レスポンス例
{ "dry_run": true, "affected_users": 25, "affected_attributes": { "clearance_level": 25 }}