Security Event Hook設定ガイド
このドキュメントの目的
Security Event Hook(セキュリティイベント通知)の設定方法を理解します。
所要時間
⏱️ 約15分
前提条件: テナント設定(security_event_log_config)
Security Event Hookを使用する前に、テナント設定で以下を有効にしてください(デフォルトは全て false):
{
"tenant": {
"security_event_log_config": {
"persistence_enabled": true,
"statistics_enabled": true,
"format": "structured_json",
"include_event_detail": true
}
}
}
| フィールド | デフォルト | 説明 |
|---|---|---|
persistence_enabled | false | true でイベントをDBに永続化。Management API でイベント照会に必須 |
statistics_enabled | false | true で統計データ(DAU/MAU/YAU、イベントカウント)を記録。統計APIに必須 |
注意: フック自体はこれらの設定に関係なく実行されますが、イベント永続化と統計記録は明示的に有効化が必要です。
Security Event Hookとは
Security Event Hookはセキュリティイベント(認証成功/失敗、トークン発行等)を外部サービスに通知する機能です。
通知先:
- Webhook(汎用HTTP通知)
- SSF(Shared Signals Framework)
- チャットサービス(Webhook経由)
- SIEM / 監視基盤(Datadog Logs Intake 等)
設定ファイル構造
security-event-hook/webhook.json
{
"id": "uuid",
"type": "WEBHOOK",
"execution_order": 1,
"triggers": [
"password_failure",
"password_success",
"oauth_authorize",
"issue_token_success"
],
"events": {
"default": {
"execution": {
"function": "http_request",
"http_request": {
"url": "${WEBHOOK_URL}/events",
"method": "POST",
"auth_type": "oauth2",
"oauth_authorization": {
"type": "client_credentials",
"token_endpoint": "${WEBHOOK_TOKEN_ENDPOINT}",
"client_authentication_type": "client_secret_post",
"client_id": "${WEBHOOK_CLIENT_ID}",
"client_secret": "${WEBHOOK_CLIENT_SECRET}"
},
"body_mapping_rules": [
{ "from": "$.type", "to": "event_type" },
{ "from": "$.user.sub", "to": "user_id" }
]
}
}
}
},
"attributes": {
"label": "Webhook通知",
"description": "セキュリティイベントをWebhookで通知"
},
"enabled": true
}
security-event-hook/ssf.json(SSF連携)
{
"id": "uuid",
"type": "SSF",
"execution_order": 1,
"triggers": [
"identity_verification_application_approved",
"fido_uaf_deregistration_success",
"user_delete"
],
"attributes": {
"label": "Security Event Framework",
"spec": "https://openid.net/specs/openid-sharedsignals-framework-1_0.html"
},
"metadata": {
"issuer": "${AUTHORIZATION_SERVER_URL}/${TENANT_ID}",
"spec_version": "1_0",
"jwks_uri": "${AUTHORIZATION_SERVER_URL}/${TENANT_ID}/v1/ssf/jwks",
"jwks": "{\"keys\":[{\"kty\":\"EC\",\"crv\":\"P-256\",\"x\":\"...\",\"y\":\"...\",\"d\":\"...\",\"use\":\"sig\",\"kid\":\"ssf-key-id\",\"alg\":\"ES256\"}]}",
"delivery_methods_supported": [
"urn:ietf:rfc:8935"
]
},
"events": {
"identity_verification_application_approved": {
"execution": {
"function": "ssf",
"details": {
"security_event_type_identifier": "https://schemas.openid.net/secevent/risc/event-type/account-enabled",
"kid": "ssf-key-id",
"url": "${SSF_RECEIVER_URL}/events/receive",
"oauth_authorization": {
"type": "client_credentials",
"token_endpoint": "${AUTH_URL}/token",
"client_authentication_type": "client_secret_post",
"client_id": "${CLIENT_ID}",
"client_secret": "${CLIENT_SECRET}"
}
}
}
}
},
"enabled": true
}
SSF Eventsセクションの詳細
構造: イベントタイプごとに異なるSSF設定を定義できます。
events: {
"{event-type-1}": { 個別設定 },
"{event-type-2}": { 個別設定 },
...
}
イベントタイプ別設定例:
{
"events": {
"user_delete": {
"execution": {
"function": "ssf",
"details": {
"security_event_type_identifier": "https://schemas.openid.net/secevent/risc/event-type/account-disabled",
"kid": "ssf-key-id",
"url": "${SSF_RECEIVER_URL_A}/user-events",
"security_event_token_additional_payload_mapping_rules": [
{
"from": "$.user.sub",
"to": "ex_sub"
}
]
}
}
},
"identity_verification_application_approved": {
"execution": {
"function": "ssf",
"details": {
"security_event_type_identifier": "https://schemas.openid.net/secevent/risc/event-type/account-enabled",
"kid": "ssf-key-id",
"url": "${SSF_RECEIVER_URL_B}/verification-events",
"oauth_authorization": {
"type": "client_credentials",
"token_endpoint": "${AUTH_URL}/token",
"client_authentication_type": "client_secret_post",
"client_id": "${CLIENT_ID}",
"client_secret": "${CLIENT_SECRET}",
"cache_enabled": true,
"cache_ttl_seconds": 3600
}
}
}
}
}
}
重要なポイント:
- イベントタイプごとに異なるURLを設定可能
- イベントタイプごとに異なる認証設定を指定可能
security_event_token_additional_payload_mapping_rulesでペイロードカスタマイズ
OAuth認証のキャッシュ設定
SSFでもOAuth 2.0認証のキャッシュを利用できます:
{
"oauth_authorization": {
"type": "client_credentials",
"token_endpoint": "${AUTH_URL}/token",
"client_authentication_type": "client_secret_post",
"client_id": "${CLIENT_ID}",
"client_secret": "${CLIENT_SECRET}",
"cache_enabled": true,
"cache_ttl_seconds": 3600,
"cache_buffer_seconds": 10
}
}
キャッシュ設定:
| フィールド | 説明 | デフォルト |
|---|---|---|
cache_enabled | キャッシュ有効化 | false |
cache_ttl_seconds | キャッシュ有効期限(秒) | - |
cache_buffer_seconds | 期限切れN秒前に再取得 | 0 |
メリット:
- Token Endpoint呼び出し回数を削減
- SSF送信のレイテンシを低減
- 大量のイベント発生時のパフォーマンス向上
主要なフィールド
基本情報
| フィールド | 必須 | 説明 |
|---|---|---|
id | ✅ | Hook設定ID(UUID) |
type | ✅ | Hookタイプ |
execution_order | ❌ | 実行順序(複数Hook時) |
triggers | ✅ | トリガーとなるイベントタイプ |
enabled | ✅ | 有効/無効 |
Triggers(イベントタイプ)
通知対象のイベントを指定:
{
"triggers": [
"password_success",
"password_failure",
"oauth_authorize",
"issue_token_success",
"user_delete"
]
}
主要なイベントタイプ:
password_success/password_failure- パスワード認証oauth_authorize- Authorization Code発行issue_token_success/issue_token_failure- トークン発行user_delete- ユーザー削除(Admin操作)user_self_delete- ユーザー自身による削除login_success/logout- セッション管理
完全なリスト: DefaultSecurityEventType.java