認証ポリシー設定ガイド(基礎編)
このドキュメントの目的
認証ポリシーの基本を理解し、シンプルな設定ができるようになることが目標です。
所要時間
⏱️ 約15分
前提条件
- パスワード認証設定完了
- 管理者トークンを取得済み
- 組織ID(organization-id)を取得済み
環境変数の準備
# 接続先サーバーURL
IDP_SERVER_URL=http://localhost:8080
Management API URL
組織レベルAPI(このドキュメントでの表記):
POST /v1/management/organizations/{organization-id}/tenants/{tenant-id}/authentication-policies
注意: システムレベルAPIとの違い
- 組織レベル:
POST /v1/management/organizations/{organization-id}/tenants/{tenant-id}/authentication-policies← このドキュメント - システムレベル:
POST /v1/management/tenants/{tenant-id}/authentication-policies← 管理者のみ
通常の運用では組織レベルAPIを使用してください。
認証ポリシーとは
どの認証方式を使って、どのような条件で認証成功とするかを定義する設定です。
Authorization Request
↓
認証ポリシー確認
├─ 利用可能な認証方式は? → available_methods
├─ 成功条件は? → success_conditions
└─ 失敗/ロック条件は? → failure_conditions, lock_conditions
↓
認証実行
Level 1: 最もシンプルなポリシー(5分)
パスワードのみの認証
curl -X POST "${IDP_SERVER_URL}/v1/management/organizations/${ORGANIZATION_ID}/tenants/${TENANT_ID}/authentication-policies" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
-d '{
"flow": "oauth",
"enabled": true,
"policies": [
{
"description": "password only",
"priority": 1,
"conditions": {},
"available_methods": ["password"],
"success_conditions": {
"any_of": [
[
{
"path": "$.password-authentication.success_count",
"type": "integer",
"operation": "gte",
"value": 1
}
]
]
}
}
]
}'
設定内容:
flow: "oauth"- OAuth/OIDC認証フローで使用available_methods: ["password"]- UIにパスワード認証を表示success_conditions.any_of- 成功条件の配列(外側はOR、内側はAND)$.password-authentication.success_count >= 1- パスワード認証が1回以上成功すれば完了
Level 2: MFA(多要素認証)ポリシー(10分)
パスワード + SMS OTP
curl -X POST "${IDP_SERVER_URL}/v1/management/organizations/${ORGANIZATION_ID}/tenants/${TENANT_ID}/authentication-policies" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
-d '{
"flow": "oauth",
"enabled": true,
"policies": [
{
"description": "password + sms mfa",
"priority": 1,
"conditions": {},
"available_methods": ["password", "sms"],
"success_conditions": {
"any_of": [
[
{
"path": "$.password-authentication.success_count",
"type": "integer",
"operation": "gte",
"value": 1
},
{
"path": "$.sms-authentication.success_count",
"type": "integer",
"operation": "gte",
"value": 1
}
]
]
}
}
]
}'
設定内容:
available_methods: ["password", "sms"]- UIに両方の認証方式を表示any_of: [[ 条件1, 条件2 ]]- 両方成功が必要(内側の配列はAND条件)
認証フロー:
1. ユーザーがパスワード入力
→ 成功
2. SMS OTP送信
→ ユーザーがOTP入力
→ 成功
3. 認証完了
Level 3: 選択式MFA(15分)
パスワード + (SMS または Email)
curl -X POST "${IDP_SERVER_URL}/v1/management/organizations/${ORGANIZATION_ID}/tenants/${TENANT_ID}/authentication-policies" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
-d '{
"flow": "oauth",
"enabled": true,
"policies": [
{
"description": "password + (sms or email)",
"priority": 1,
"conditions": {},
"available_methods": ["password", "sms", "email"],
"success_conditions": {
"any_of": [
[
{
"path": "$.password-authentication.success_count",
"type": "integer",
"operation": "gte",
"value": 1
},
{
"path": "$.sms-authentication.success_count",
"type": "integer",
"operation": "gte",
"value": 1
}
],
[
{
"path": "$.password-authentication.success_count",
"type": "integer",
"operation": "gte",
"value": 1
},
{
"path": "$.email-authentication.success_count",
"type": "integer",
"operation": "gte",
"value": 1
}
]
]
}
}
]
}'
設定内容:
- パスワード必須
- SMS または Email(ユーザーが選択)
any_of: [[ パスワード, SMS ], [ パスワード, Email ]]- どちらかのグループを満たせばOK
認証フロー:
1. ユーザーがパスワード入力
→ 成功
2. ユーザーが選択
- SMSを選択 → SMS OTP認証
- Emailを選択 → Email OTP認証
3. 認証完了
success_conditionsの基本
any_of構造
{
"success_conditions": {
"any_of": [
[ 条件グループ1 ], // このグループ内の条件は全てAND
[ 条件グループ2 ] // グループ間はOR
]
}
}
| 構造 | 意味 | 例 |
|---|---|---|
any_of: [[ 条件1, 条件2 ]] | 全て成功が必要(AND) | パスワード かつ SMS OTP |
any_of: [[ 条件1 ], [ 条件2 ]] | いずれか1つ成功でOK(OR) | パスワード または SMS OTP |
パターン1: AND条件(MFA)
{
"success_conditions": {
"any_of": [
[
{
"path": "$.password-authentication.success_count",
"type": "integer",
"operation": "gte",
"value": 1
},
{
"path": "$.sms-authentication.success_count",
"type": "integer",
"operation": "gte",
"value": 1
}
]
]
}
}
意味: パスワード AND SMS OTP
フロー:
password成功 → sms成功 → 認証完了
password失敗 → 認証失敗
sms失敗 → 認証失敗
パターン2: OR条件
{
"success_conditions": {
"any_of": [
[
{
"path": "$.password-authentication.success_count",
"type": "integer",
"operation": "gte",
"value": 1
}
],
[
{
"path": "$.sms-authentication.success_count",
"type": "integer",
"operation": "gte",
"value": 1
}
],
[
{
"path": "$.fido2-authentication.success_count",
"type": "integer",
"operation": "gte",
"value": 1
}
]
]
}
}
意味: パスワード OR SMS OTP OR FIDO2
フロー:
passwordで成功 → 認証完了(sms、fido2は不要)
smsで成功 → 認証完了
fido2で成功 → 認証完了
パターン3: AND + OR(選択式MFA)
{
"success_conditions": {
"any_of": [
[
{ "path": "$.password-authentication.success_count", "type": "integer", "operation": "gte", "value": 1 },
{ "path": "$.sms-authentication.success_count", "type": "integer", "operation": "gte", "value": 1 }
],
[
{ "path": "$.password-authentication.success_count", "type": "integer", "operation": "gte", "value": 1 },
{ "path": "$.email-authentication.success_count", "type": "integer", "operation": "gte", "value": 1 }
],
[
{ "path": "$.password-authentication.success_count", "type": "integer", "operation": "gte", "value": 1 },
{ "path": "$.fido2-authentication.success_count", "type": "integer", "operation": "gte", "value": 1 }
]
]
}
}
意味: パスワード AND (SMS OR Email OR FIDO2)
フロー:
1. password必須
2. sms、email、fido2のいずれか1つ
JSONPath条件の書き方
| フィールド | 説明 | 例 |
|---|---|---|
path | JSONPath形式で認証結果を参照 | $.password-authentication.success_count |
type | 値の型 | integer, string, boolean |
operation | 比較演算子 | gte, lte, eq, gt, lt |
value | 比較する値 | 1 |
利用可能なpath例:
$.password-authentication.success_count- パスワード認証成功回数$.sms-authentication.success_count- SMS認証成功回数$.email-authentication.success_count- Email認証成功回数$.fido2-authentication.success_count- FIDO2認証成功回数$.fido-uaf-authentication.success_count- FIDO UAF認証成功回数$.password-authentication.failure_count- パスワード認証失敗回数
Level 4: 認証失敗・アカウントロック条件(failure_conditions / lock_conditions)
failure_conditions(認証失敗条件)
failure_conditions は、認証失敗と判定する条件を定義します。success_conditions と同じ any_of 構造を使用します。
例えば、パスワード認証が3回失敗した場合に認証失敗と判定するには、以下のように設定します。
{
"failure_conditions": {
"any_of": [
[
{
"path": "$.password-authentication.failure_count",
"type": "integer",
"operation": "gte",
"value": 3
}
]
]
}
}
設定内容:
$.password-authentication.failure_count- パスワード認証の失敗回数を参照operation: "gte"+value: 3- 3回以上失敗したら認証失敗と判定- 認証失敗と判定されると、そのセッションでの認証試行が終了する
lock_conditions(アカウントロック条件)
lock_conditions は、アカウントをロックする条件を定義します。failure_conditions と同じ条件構造を使用します。
ロック条件が満たされると、アカウントがロックされます。ロック中 は正しいパスワードを入力しても認証が拒否されます。ロックは password_policy.lockout_duration_seconds で設定した時間が経過すると自動的に解除されます。
{
"lock_conditions": {
"any_of": [
[
{
"path": "$.password-authentication.failure_count",
"type": "integer",
"operation": "gte",
"value": 5
}
]
]
}
}
設定内容:
- パスワード認証が5回以上失敗した場合にアカウントをロック
- ロック中は
lockout_duration_seconds(デフォルト: 900秒 = 15分)経過後に自動解除
完全な設定例(success_conditions + failure_conditions + lock_conditions)
以下は、成功条件・失敗条件・ロック条件を全て含む認証ポリシーの設定例です。
curl -X POST "${IDP_SERVER_URL}/v1/management/organizations/${ORGANIZATION_ID}/tenants/${TENANT_ID}/authentication-policies" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
-d '{
"flow": "oauth",
"enabled": true,
"policies": [
{
"description": "password with brute-force protection",
"priority": 1,
"conditions": {},
"available_methods": ["password"],
"success_conditions": {
"any_of": [
[
{
"path": "$.password-authentication.success_count",
"type": "integer",
"operation": "gte",
"value": 1
}
]
]
},
"failure_conditions": {
"any_of": [
[
{
"path": "$.password-authentication.failure_count",
"type": "integer",
"operation": "gte",
"value": 3
}
]
]
},
"lock_conditions": {
"any_of": [
[
{
"path": "$.password-authentication.failure_count",
"type": "integer",
"operation": "gte",
"value": 5
}
]
]
}
}
]
}'
動作フロー:
パスワード認証試行
├─ 成功(1回以上成功) → 認証完了
├─ 失敗3回 → failure_conditions発動 → 認証失敗(セッション終了)
└─ 失敗5回 → lock_conditions発動 → アカウントロック
└─ lockout_duration_seconds 経過後 → 自動解除
注意: failure_conditions と lock_conditions の閾値は、failure_conditions の値を lock_conditions の値以下に設定してください。上記の例では、3回失敗で認証失敗(再試行が必要)、5回失敗でアカウントロック(一定時間認証不可)となります。
Level 5: 複数ポリシー(priority)
クライアント別のポリシー
curl -X POST "${IDP_SERVER_URL}/v1/management/organizations/${ORGANIZATION_ID}/tenants/${TENANT_ID}/authentication-policies" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
-d '{
"flow": "oauth",
"enabled": true,
"policies": [
{
"description": "admin app - high security",
"priority": 100,
"conditions": {
"client_ids": ["admin-app"]
},
"available_methods": ["password", "fido2"],
"success_conditions": {
"any_of": [
[
{ "path": "$.password-authentication.success_count", "type": "integer", "operation": "gte", "value": 1 },
{ "path": "$.fido2-authentication.success_count", "type": "integer", "operation": "gte", "value": 1 }
]
]
}
},
{
"description": "normal app - standard security",
"priority": 50,
"conditions": {
"client_ids": ["user-app"]
},
"available_methods": ["password"],
"success_conditions": {
"any_of": [
[
{ "path": "$.password-authentication.success_count", "type": "integer", "operation": "gte", "value": 1 }
]
]
}
},
{
"description": "default - password only",
"priority": 1,
"conditions": {},
"available_methods": ["password"],
"success_conditions": {
"any_of": [
[
{ "path": "$.password-authentication.success_count", "type": "integer", "operation": "gte", "value": 1 }
]
]
}
}
]
}'
動作:
admin-app からのリクエスト
→ priority 100 にマッチ(最優先)
→ パスワード + FIDO2(高セキュリティ)
user-app からのリクエスト
→ priority 50 にマッチ
→ パスワードのみ(標準セキュリティ)
other-app からのリクエスト
→ priority 1 にマッチ(デフォルト・最低優先度)
→ パスワードのみ
重要: priorityが大きいほど優先(100 > 50 > 1)
Level 6: ACRマッピング(基礎)
ACR(Authentication Context Class Reference)とは
認証の強度レベルを示す標準的な値です。
ユーザー認証完了
↓
どの認証方式を使った?
- FIDO2 → ACR: urn:mace:incommon:iap:gold(高)
- SMS OTP → ACR: urn:mace:incommon:iap:silver(中)
- パスワード → ACR: urn:mace:incommon:iap:bronze(低)
↓
ID Tokenに acr クレームとして含める
ACRマッピング設定
{
"flow": "oauth",
"enabled": true,
"policies": [
{
"description": "with acr mapping",
"priority": 1,
"conditions": {},
"available_methods": ["password", "sms", "fido2"],
"acr_mapping_rules": {
"urn:mace:incommon:iap:gold": ["fido2"],
"urn:mace:incommon:iap:silver": ["sms", "email"],
"urn:mace:incommon:iap:bronze": ["password"]
},
"success_conditions": {
"any_of": [
[{ "path": "$.password-authentication.success_count", "type": "integer", "operation": "gte", "value": 1 }],
[{ "path": "$.sms-authentication.success_count", "type": "integer", "operation": "gte", "value": 1 }],
[{ "path": "$.fido2-authentication.success_count", "type": "integer", "operation": "gte", "value": 1 }]
]
}
}
]
}
効果:
// FIDO2認証した場合のID Token
{
"sub": "user-12345",
"acr": "urn:mace:incommon:iap:gold", // 高レベル
...
}
// パスワード認証した場合のID Token
{
"sub": "user-12345",
"acr": "urn:mace:incommon:iap:bronze", // 低レベル
...
}
用途:
- クライアントがACR値を確認してアクセス制御
- 重要操作は
goldレベル必須等
詳細: 認証ポリシー詳細ガイド