外部IdP連携(Federation)の設定
このドキュメントの目的
Google でログインのような外部IdP(Identity Provider)連携を設定することが目標です。
所要時間
⏱️ 約20分
前提条件
- 管理者トークンを取得済み
- 外部IdP(Google、Azure AD等)でOAuthクライアント登録済み
- 組織ID(organization-id)を取得済み
Management API URL
組織レベルAPI(このドキュメントでの表記):
POST /v1/management/organizations/{organization-id}/tenants/{tenant-id}/federation-configurations
注意: システムレベルAPIとの違い
- 組織レベル:
POST /v1/management/organizations/{organization-id}/tenants/{tenant-id}/federation-configurations← このドキュメント - システムレベル:
POST /v1/management/tenants/{tenant-id}/federation-configurations← 管理者のみ
通常の運用では組織レベルAPIを使用してください。
Federationとは
ユーザーが既存のアカウント(Google、Azure AD等)でログインできるようにする仕組みです。
ユーザー
↓ 「Googleでログイン」をクリック
Googleの認証画面
↓ Google認証成功
idp-server
↓ Googleからユーザー情報取得
↓ idp-serverのユーザーとして認証完了
Authorization Code発行
メリット:
- ✅ ユーザーは新しいパスワードを覚える必要なし
- ✅ 企業SSO(Google Workspace、Azure AD)と統合
- ✅ セキュリティ向上(外部IdPのMFAを利用)
設定要素の関係(概要)
Federation認証には3つの設定が連携します:
┌──────────────────┐ ┌──────────────────────┐ ┌──────────────────┐
│ Client │ │ Authentication │ │ Federation │
│ │ │ Policy │ │ Configuration │
├──────────────────┤ ├──────────────────────┤ ├──────────────────┤
│ extension: │ │ available_methods: │ │ sso_provider: │
│ available_ │───▶│ - "oidc-google" ◀───┼────│ "google" │
│ federations: │ │ │ │ │
│ sso_provider: │ │ success_conditions: │ │ payload: │
│ "google" │ │ oidc-google >= 1 │ │ issuer, ... │
└──────────────────┘ └──────────────────────┘ └──────────────────┘
命名規則: oidc-{sso_provider} でAuthentication PolicyとFederation Configurationが紐づく
📖 詳細: Federation設定ガイド
例: Google連携を設定
Step 1: Googleでクライアント登録
Google Cloud Consoleで事前準備:
-
プロジェクト作成
-
OAuth 2.0クライアント作成
- アプリケーションタイプ: ウェブアプリケーション
- 承認済みのリダイレクトURI:
http://localhost:8080/{tenant-id}/v1/authorizations/federations/oidc/callback
-
クライアントID・シークレット取得
- クライアントID:
123456789-abcdefg.apps.googleusercontent.com - クライアントシークレット:
GOCSPX-xxxxxxxxxxxxx
- クライアントID:
Step 2: idp-serverでFederation設定
IDP_SERVER_URL=http://localhost:8080
curl -X POST "${IDP_SERVER_URL}/v1/management/organizations/${ORGANIZATION_ID}/tenants/${TENANT_ID}/federation-configurations" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
-d '{
"type": "oidc",
"sso_provider": "google",
"enabled": true,
"payload": {
"type": "standard",
"provider": "standard",
"issuer": "https://accounts.google.com",
"issuer_name": "google",
"authorization_endpoint": "https://accounts.google.com/o/oauth2/v2/auth",
"token_endpoint": "https://oauth2.googleapis.com/token",
"userinfo_endpoint": "https://openidconnect.googleapis.com/v1/userinfo",
"client_id": "123456789-abcdefg.apps.googleusercontent.com",
"client_secret": "GOCSPX-xxxxxxxxxxxxx",
"redirect_uri": "http://localhost:8080/${TENANT_ID}/v1/authorizations/federations/oidc/callback",
"scopes_supported": ["openid", "profile", "email"],
"userinfo_mapping_rules": [
{"from": "$.http_request.response_body.sub", "to": "external_user_id"},
{"from": "$.http_request.response_body.email", "to": "email"},
{"from": "$.http_request.response_body.name", "to": "name"},
{"from": "$.http_request.response_body.picture", "to": "picture"}
]
}
}'
重要なフィールド:
payload.type: プロトコル種別(standard=標準OIDC)payload.provider: Executorタイプ(standard/oauth-extension/facebook)payload.issuer_name: IdP識別名( ユーザーのexternal_idp_issuerに設定される)payload.redirect_uri: コールバックURL(外部IdPに登録するURL)payload.userinfo_mapping_rules: UserInfo→idp-serverユーザーへのマッピング(詳細はuserinfo_mapping_rulesの詳細を参照)
レスポンス:
{
"dry_run": false,
"result": {
"id": "770e8400-e29b-41d4-a716-446655440002",
"type": "oidc",
"sso_provider": "google",
"enabled": true,
...
}
}
設定内容:
sso_provider: "google"- Google連携を識別payload.issuer- Googleの発行者URLpayload.issuer_name- IdP識別名payload.provider- Executorタイプ(standard=標準OIDCフロー)payload.scopes_supported- Googleから取得する情報(openid, profile, email)payload.userinfo_mapping_rules- Googleのユーザー情報 → idp-serverのユーザー属性マッピング
Step 3: 認証ポリシーでFederationを許可
curl -X PUT "${IDP_SERVER_URL}/v1/management/organizations/${ORGANIZATION_ID}/tenants/${TENANT_ID}/authentication-policies/oauth" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
-d '{
"flow": "oauth",
"available_methods": ["password", "oidc-google"],
"success_conditions": {
"any_of": [
[
{
"path": "$.password-authentication.success_count",
"type": "integer",
"operation": "gte",
"value": 1
}
],
[
{
"path": "$.oidc-google.success_count",
"type": "integer",
"operation": "gte",
"value": 1
}
]
]
}
}'
設定内容:
available_methodsに"oidc-google"を追加success_conditions.any_of- パスワード認証またはGoogle認証のいずれかが1回以上成功すればOK
Step 4: クライアントでFederationを有効化
Step 2で作成したフェデレーション設定のIDを使用して、クライアントにFederationを設定します。
# FEDERATION_ID は Step 2 のレスポンスで取得した id を使用
FEDERATION_ID="770e8400-e29b-41d4-a716-446655440002"
curl -X PUT "${IDP_SERVER_URL}/v1/management/organizations/${ORGANIZATION_ID}/tenants/${TENANT_ID}/clients/${CLIENT_ID}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
-d '{
"extension": {
"available_federations": [
{
"id": "'${FEDERATION_ID}'",
"type": "oidc",
"sso_provider": "google"
}
]
}
}'
設定内容:
extension.available_federationsにフェデレーション設定を追加id: Step 2で作成したフェデレーション設定のIDtype: プロトコルタイプ(oidc)sso_provider: IdP識別子(google)
Step 5: 動作確認
5.1 Authorization Request(通常通り)
curl -v "${IDP_SERVER_URL}/${TENANT_ID}/v1/authorizations?\
response_type=code&\
client_id=${CLIENT_ID}&\
redirect_uri=${REDIRECT_URI}&\
scope=openid+profile+email&\
state=random-state"
レスポンス: ログイン画面にリダイレクト
表示される選択肢:
- パスワードでログイン
- Googleでログイン ← NEW!
5.2 Googleでログイン
ユーザーが「Googleでログイン」をクリック:
# フロントエンドから実行
POST /{tenant-id}/v1/authentications/${AUTH_TRANSACTION_ID}/federations/oidc/google
レスポンス:
{
"redirect_uri": "https://accounts.google.com/o/oauth2/v2/auth?client_id=...&state=...&nonce=..."
}
5.3 Googleの認証画面
ユーザーはGoogleの認証画面にリダイレクト:
1. Googleアカウントでログイン
2. idp-serverへのアクセス許可
3. Callback URLにリダイレクト
5.4 Callback処理(自動)
idp-serverが自動処理:
1. Googleから認証コード受け取り
2. GoogleへToken Request
3. GoogleのID Token検証
4. UserInfo取得
5. idp-serverのユーザー作成/更新
6. Authorization Code発行
5.5 トークン取得(通常通り)
curl -X POST "${IDP_SERVER_URL}/${TENANT_ID}/v1/tokens" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u "${CLIENT_ID}:${CLIENT_SECRET}" \
-d "grant_type=authorization_code&code=abc123&redirect_uri=${REDIRECT_URI}"
成功!
他の外部IdP設定例
Azure AD連携
{
"type": "oidc",
"sso_provider": "azure_ad",
"enabled": true,
"payload": {
"type": "standard",
"provider": "standard",
"issuer": "https://login.microsoftonline.com/{azure-tenant-id}/v2.0",
"issuer_name": "azure_ad",
"authorization_endpoint": "https://login.microsoftonline.com/{azure-tenant-id}/oauth2/v2.0/authorize",
"token_endpoint": "https://login.microsoftonline.com/{azure-tenant-id}/oauth2/v2.0/token",
"userinfo_endpoint": "https://graph.microsoft.com/oidc/userinfo",
"client_id": "your-client-id",
"client_secret": "your-client-secret",
"redirect_uri": "http://localhost:8080/${TENANT_ID}/v1/authorizations/federations/oidc/callback",
"scopes_supported": ["openid", "profile", "email"],
"userinfo_mapping_rules": [
{"from": "$.http_request.response_body.sub", "to": "external_user_id"},
{"from": "$.http_request.response_body.email", "to": "email"},
{"from": "$.http_request.response_body.name", "to": "name"},
{"from": "$.http_request.response_body.preferred_username", "to": "preferred_username"}
]
}
}
カスタムOIDCプロバイダー
{
"type": "oidc",
"sso_provider": "custom-idp",
"enabled": true,
"payload": {
"type": "standard",
"provider": "standard",
"issuer": "https://your-idp.example.com",
"issuer_name": "custom-idp",
"authorization_endpoint": "https://your-idp.example.com/oauth2/authorize",
"token_endpoint": "https://your-idp.example.com/oauth2/token",
"userinfo_endpoint": "https://your-idp.example.com/oauth2/userinfo",
"client_id": "your-client-id",
"client_secret": "your-client-secret",
"redirect_uri": "http://localhost:8080/${TENANT_ID}/v1/authorizations/federations/oidc/callback",
"scopes_supported": ["openid", "profile", "email"],
"userinfo_mapping_rules": [
{"from": "$.http_request.response_body.sub", "to": "external_user_id"},
{"from": "$.http_request.response_body.email", "to": "email"},
{"from": "$.http_request.response_body.name", "to": "name"},
{"from": "$.http_request.response_body.custom_claims.department", "to": "custom_properties.department"},
{"from": "$.http_request.response_body.custom_claims.employee_id", "to": "custom_properties.employee_id"}
]
}
}