アクセストレース
概要
アクセストレースAPIは、アプリケーション内で行われた権限チェックの監査ログと統計情報を提供します。どのユーザーがどのリソースにアクセスしようとしたか、その結果が許可/拒否されたかを追跡できます。
エンドポイント一覧
| メソッド | エンドポイント | 説明 |
|---|---|---|
| GET | /api/admin/access-trace | アクセストレース一覧取得 |
| GET | /api/admin/access-trace/:id | アクセストレース詳細取得 |
| GET | /api/admin/access-trace/stats | アクセストレース統計取得 |
| GET | /api/admin/access-trace/timeline | タイムラインデータ取得 |
アクセストレース一覧取得
権限チェックの履歴を取得します。
エンドポイント
GET /api/admin/access-trace
クエリパラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
limit | integer | - | 取得件数(デフォルト: 50、最大: 100) |
cursor | string | - | ページネーションカーソル |
user_id | string | - | ユーザーIDでフィルタ |
resource | string | - | リソースでフィルタ |
action | string | - | アクションでフィルタ |
decision | string | - | 結果でフィルタ(allow, deny) |
start_date | string | - | 開始日時(ISO 8601形式) |
end_date | string | - | 終了日時(ISO 8601形式) |
リクエスト例
curl -X GET "https://{tenant-domain}/api/admin/access-trace?decision=deny&limit=20" \ -H "Authorization: Bearer {token}"レスポンス例
{ "items": [ { "id": "trace_abc123", "timestamp": "2024-01-22T10:30:00Z", "user_id": "usr_xyz789", "resource": "documents:report_2024", "action": "write", "decision": "deny", "reason": "Insufficient permissions", "client_id": "client_app001", "ip_address": "203.0.113.1", "duration_ms": 5 }, { "id": "trace_def456", "timestamp": "2024-01-22T10:25:00Z", "user_id": "usr_abc123", "resource": "settings:security", "action": "read", "decision": "allow", "client_id": "client_app001", "ip_address": "203.0.113.2", "duration_ms": 3 } ], "total": 1500, "cursor": "eyJpZCI6InRyYWNlX2RlZjQ1NiJ9"}アクセストレース詳細取得
指定されたアクセストレースの詳細情報を取得します。
エンドポイント
GET /api/admin/access-trace/:id
パスパラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
id | string | ○ | アクセストレースID |
リクエスト例
curl -X GET "https://{tenant-domain}/api/admin/access-trace/trace_abc123" \ -H "Authorization: Bearer {token}"レスポンス例
{ "id": "trace_abc123", "timestamp": "2024-01-22T10:30:00Z", "user": { "id": "usr_xyz789", "name": "山田 太郎", "roles": ["viewer"] }, "resource": "documents:report_2024", "action": "write", "decision": "deny", "reason": "Insufficient permissions", "evaluation": { "type": "rbac", "checked_permissions": ["documents:write"], "user_permissions": ["documents:read"], "missing_permissions": ["documents:write"] }, "policies_evaluated": [ { "id": "policy_default", "name": "default-viewer-policy", "effect": "allow", "matched": false, "reason": "Action 'write' not in allowed actions" } ], "context": { "client_id": "client_app001", "client_name": "My App", "ip_address": "203.0.113.1", "user_agent": "Mozilla/5.0...", "session_id": "sess_xyz789", "request_id": "req_abc123" }, "duration_ms": 5}アクセストレース統計取得
アクセスチェックの統計情報を取得します。
エンドポイント
GET /api/admin/access-trace/stats
クエリパラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
start_date | string | - | 開始日時(ISO 8601形式) |
end_date | string | - | 終了日時(ISO 8601形式) |
group_by | string | - | グルーピング(user, resource, action, decision) |
リクエスト例
curl -X GET "https://{tenant-domain}/api/admin/access-trace/stats?start_date=2024-01-01&end_date=2024-01-31" \ -H "Authorization: Bearer {token}"レスポンス例
{ "period": { "start": "2024-01-01T00:00:00Z", "end": "2024-01-31T23:59:59Z" }, "summary": { "total_checks": 125000, "allowed": 120000, "denied": 5000, "allow_rate": 96.0, "avg_duration_ms": 4.5 }, "by_decision": { "allow": 120000, "deny": 5000 }, "by_resource": [ { "resource": "documents:*", "total": 50000, "allowed": 48000, "denied": 2000 }, { "resource": "settings:*", "total": 30000, "allowed": 29500, "denied": 500 } ], "by_action": [ { "action": "read", "total": 80000, "allowed": 79000, "denied": 1000 }, { "action": "write", "total": 35000, "allowed": 32000, "denied": 3000 } ], "top_denied_users": [ { "user_id": "usr_xyz789", "denied_count": 500 } ], "top_denied_resources": [ { "resource": "admin:settings", "denied_count": 1500 } ]}タイムラインデータ取得
時系列のアクセスチェックデータを取得します(チャート表示用)。
エンドポイント
GET /api/admin/access-trace/timeline
クエリパラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
start_date | string | ○ | 開始日時(ISO 8601形式) |
end_date | string | ○ | 終了日時(ISO 8601形式) |
interval | string | - | 間隔(hour, day, week、デフォルト: day) |
decision | string | - | 結果でフィルタ |
リクエスト例
curl -X GET "https://{tenant-domain}/api/admin/access-trace/timeline?start_date=2024-01-15&end_date=2024-01-22&interval=day" \ -H "Authorization: Bearer {token}"レスポンス例
{ "interval": "day", "data": [ { "timestamp": "2024-01-15T00:00:00Z", "total": 18000, "allowed": 17500, "denied": 500, "avg_duration_ms": 4.2 }, { "timestamp": "2024-01-16T00:00:00Z", "total": 19500, "allowed": 19000, "denied": 500, "avg_duration_ms": 4.5 }, { "timestamp": "2024-01-17T00:00:00Z", "total": 17000, "allowed": 16200, "denied": 800, "avg_duration_ms": 4.8 }, { "timestamp": "2024-01-18T00:00:00Z", "total": 20000, "allowed": 19500, "denied": 500, "avg_duration_ms": 4.3 }, { "timestamp": "2024-01-19T00:00:00Z", "total": 12000, "allowed": 11800, "denied": 200, "avg_duration_ms": 3.9 }, { "timestamp": "2024-01-20T00:00:00Z", "total": 8000, "allowed": 7900, "denied": 100, "avg_duration_ms": 3.5 }, { "timestamp": "2024-01-21T00:00:00Z", "total": 10000, "allowed": 9800, "denied": 200, "avg_duration_ms": 3.7 }, { "timestamp": "2024-01-22T00:00:00Z", "total": 21000, "allowed": 20300, "denied": 700, "avg_duration_ms": 4.6 } ]}アクセストレースの活用例
セキュリティ監視
拒否されたアクセスを監視して、不正なアクセス試行を検出します。
# 過去1時間の拒否されたアクセスを取得curl -X GET "https://{tenant-domain}/api/admin/access-trace?decision=deny&start_date=$(date -u -v-1H +%Y-%m-%dT%H:%M:%SZ)" \ -H "Authorization: Bearer {token}"権限の最適化
頻繁に拒否されているリソースを特定し、必要に応じて権限を見直します。
# 統計から最も拒否が多いリソースを確認curl -X GET "https://{tenant-domain}/api/admin/access-trace/stats?group_by=resource" \ -H "Authorization: Bearer {token}"パフォーマンス分析
権限チェックの応答時間を監視し、ボトルネックを特定します。
# タイムラインで応答時間の推移を確認curl -X GET "https://{tenant-domain}/api/admin/access-trace/timeline?start_date=2024-01-01&end_date=2024-01-31&interval=day" \ -H "Authorization: Bearer {token}"データ保持
アクセストレースのデータは、テナントのデータ保持ポリシーに従って保持されます。デフォルトの保持期間は30日です。コンプライアンスAPIで保持期間を変更できます。