EndUserセッション管理
概要
EndUserセッション管理APIは、エンドユーザーのアクティブセッションを管理するためのエンドポイントを提供します。セッションの一覧取得、個別またはユーザー単位での失効操作が可能です。
エンドポイント一覧
| メソッド | エンドポイント | 説明 |
|---|---|---|
| GET | /api/admin/sessions | セッション一覧取得 |
| GET | /api/admin/sessions/:id | セッション詳細取得 |
| DELETE | /api/admin/sessions/:id | セッション失効 |
| POST | /api/admin/users/:id/logout | ユーザーの全セッション失効 |
| POST | /api/admin/sessions/revoke-all | 全セッション失効 |
セッション一覧取得
テナント内のアクティブセッション一覧を取得します。
エンドポイント
GET /api/admin/sessions
クエリパラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
limit | integer | - | 取得件数(デフォルト: 20、最大: 100) |
cursor | string | - | ページネーションカーソル |
user_id | string | - | 特定ユーザーのセッションのみ |
client_id | string | - | 特定クライアントのセッションのみ |
active_only | boolean | - | アクティブセッションのみ(デフォルト: true) |
リクエスト例
curl -X GET "https://{tenant-domain}/api/admin/sessions?user_id=usr_abc123" \ -H "Authorization: Bearer {token}"レスポンス例
{ "items": [ { "id": "sess_xyz789", "user_id": "usr_abc123", "client_id": "client_def456", "client_name": "My Web App", "ip_address": "203.0.113.1", "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)...", "device_info": { "type": "desktop", "os": "macOS", "browser": "Chrome" }, "location": { "country": "JP", "city": "Tokyo" }, "created_at": 1705881600, "last_activity_at": 1706054400, "expires_at": 1706486400 } ], "total": 3, "cursor": null}セッション詳細取得
指定されたセッションの詳細情報を取得します。
エンドポイント
GET /api/admin/sessions/:id
パスパラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
id | string | ○ | セッションID |
リクエスト例
curl -X GET "https://{tenant-domain}/api/admin/sessions/sess_xyz789" \ -H "Authorization: Bearer {token}"レスポンス例
{ "id": "sess_xyz789", "user_id": "usr_abc123", "user_name": "山田 太郎", "client_id": "client_def456", "client_name": "My Web App", "ip_address": "203.0.113.1", "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)...", "device_info": { "type": "desktop", "os": "macOS", "os_version": "10.15.7", "browser": "Chrome", "browser_version": "120.0.0" }, "location": { "country": "JP", "country_name": "Japan", "region": "Tokyo", "city": "Tokyo", "latitude": 35.6762, "longitude": 139.6503 }, "auth_method": "password", "mfa_verified": true, "scopes": ["openid", "profile", "email"], "created_at": 1705881600, "last_activity_at": 1706054400, "expires_at": 1706486400}セッション失効
指定されたセッションを失効させます。
エンドポイント
DELETE /api/admin/sessions/:id
パスパラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
id | string | ○ | セッションID |
リクエスト例
curl -X DELETE "https://{tenant-domain}/api/admin/sessions/sess_xyz789" \ -H "Authorization: Bearer {token}"レスポンス
ステータスコード 204 No Content(ボディなし)
ユーザーの全セッション失効
指定されたユーザーのすべてのアクティブセッションを失効させます。強制ログアウトに使用します。
エンドポイント
POST /api/admin/users/:id/logout
パスパラメータ
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
id | string | ○ | ユーザーID |
リクエストボディ
| フィールド | 型 | 必須 | 説明 |
|---|---|---|---|
reason | string | - | ログアウト理由 |
リクエスト例
curl -X POST "https://{tenant-domain}/api/admin/users/usr_abc123/logout" \ -H "Authorization: Bearer {token}" \ -H "Content-Type: application/json" \ -d '{ "reason": "パスワード変更に伴う強制ログアウト" }'レスポンス例
{ "user_id": "usr_abc123", "revoked_sessions": 3, "revoked_at": 1706140800}全セッション失効
テナント内のすべてのアクティブセッションを失効させます。緊急時のセキュリティ対応などに使用します。
エンドポイント
POST /api/admin/sessions/revoke-all
リクエストボディ
| フィールド | 型 | 必須 | 説明 |
|---|---|---|---|
reason | string | ○ | 失効理由(監査ログ用) |
exclude_admin | boolean | - | 管理者セッションを除外(デフォルト: false) |
リクエスト例
curl -X POST "https://{tenant-domain}/api/admin/sessions/revoke-all" \ -H "Authorization: Bearer {token}" \ -H "Content-Type: application/json" \ -d '{ "reason": "セキュリティインシデント対応", "exclude_admin": true }'レスポンス例
{ "revoked_sessions": 1250, "revoked_at": 1706227200, "excluded_admin_sessions": 5}セッションの有効期限
セッションの有効期限はテナント設定で管理されます。デフォルト値:
| 設定 | デフォルト値 | 説明 |
|---|---|---|
session_lifetime | 86400秒(24時間) | セッションの最大有効期間 |
idle_timeout | 3600秒(1時間) | アイドルタイムアウト |
absolute_timeout | 604800秒(7日) | 絶対タイムアウト |
これらの設定は設定管理APIで変更できます。