Federation設定ガイド
このドキュメントの目的
外部IdP連携(Federation)の設定方法を理解します。
所要時間
⏱️ 約20分
Federationとは
**Federation(フェデレーション)**は外部Identity Provider(IdP)と連携してユーザー認証を行う機能です。
ユースケース:
- 既存の企業IdPと連携
- ソーシャルログイン(外部OIDC準拠IdP等)
- 他システムの認証情報を利用
設定の関係性
Federation認証を構成する3つの設定要素の関係を示します。
┌─────────────────────────────────────────────────────────────────────────────────┐
│ Consumer Tenant (認証を受ける側) │
├─────────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌────── ────────────┐ ┌──────────────────────┐ ┌──────────────────┐ │
│ │ Client │ │ Authentication │ │ Federation │ │
│ │ │ │ Policy │ │ Configuration │ │
│ ├──────────────────┤ ├──────────────────────┤ ├──────────────────┤ │
│ │ client_id │ │ flow: "oauth" │ │ type: "oidc" │ │
│ │ scope: │─────▶│ conditions: │ │ sso_provider: │ │
│ │ "openid email" │ │ scopes: ["openid"] │ │ "google" │ │
│ │ redirect_uris │ │ │ │ │ │
│ └──────────────────┘ │ available_methods: │ │ payload: │ │
│ │ - "password" │ │ provider: │ │
│ scope参照 │ - "oidc-google" ◀──┼──────┤ "standard" │ │
│ │ │ │ │ issuer: ... │ │
│ ▼ │ success_conditions: │ │ client_id: ... │ │
│ ┌──────────────────────┐ │ oidc-google の │ │ userinfo_ │ │
│ │ 認可リクエスト │ │ success_count >= 1 │ │ mapping_rules │ │
│ │ GET /authorizations │ └──────────────────────┘ └────────┬─────────┘ │
│ │ ?scope=openid │ │ │ │
│ │ &client_id=xxx │ │ │ │
│ └──────────┬───────────┘ │ │ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────────┐ │
│ │ 認可フロー処理 │ │
│ │ 1. Client検証 → 2. Policy評価 → 3. 利用可能な認証方法を提示 │ │
│ │ (password, oidc-google) │ │
│ └─────────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ │ユーザーがFederation選択 │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────────┐ │
│ │ Federation開始: POST /{tenant}/v1/authorizations/{id}/federations/oidc │ │
│ │ → Federation Configurationを参照してProvider IdPにリダイレクト │ │
│ └─────────────────────────────────────────────────────────────────────────┘ │
│ │ │
└────────────────────────────────────────┼───────────────────────────────────────┘
│
▼
┌─────────────────────────────── ──────────────────────────────────────────────────┐
│ Provider Tenant (外部IdP) │
├─────────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────────────────────────────────────────────────────────────────┐ │
│ │ Authorization Server │ │
│ │ claims_supported: ["sub", "name", "email", "preferred_username"] │ │
│ │ ^^^^^^^^^^^^^^^^ ← これがないとUserInfoでemailが返らない! │ │
│ └──────────────────────────────────────────────────────────────────────────┘ │
│ │
│ 認証完了後、Consumer Tenantのcallback URLにリダイレクト: │
│ /{consumer-tenant}/v1/authorizations/federations/oidc/callback │
│ │
└─────────────────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────────────┐
│ Consumer Tenant (Callback処理) │
├─────────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────────────────────────┐ │
│ │ OidcFederationInteractor.callback() │ │
│ │ 1. code → token交換 │ │
│ │ 2. UserInfo取得 │ │
│ │ 3. userinfo_mapping_rules でUser属性マッピング │ │
│ │ 4. applyIdentityPolicy() で preferred_username 設定 │ │
│ └─────────────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────────┘
設定要素の紐づけ
┌─────────────────────────────────────┐
│ Client │
│ scope: "openid email" │
│ extension: │
│ available_federations: │
│ - id: {federation_config_id} │
│ type: "oidc" │
│ sso_provider: "google" ─────┼──────────┐
│ auto_selected: true │ │
└─────────────────┬───────────────────┘ │
│ scope参照 │ sso_provider参照
▼ ▼
┌─────────────────────────────┐ ┌─────────────────────────────┐
│ Authentication Policy │ │ Federation Configuration │
│ │ │ │
│ conditions: │ │ id: {federation_config_id} │
│ scopes: ["openid"] │ │ type: "oidc" │
│ │ │ sso_provider: "google" ◀────┼── 一致
│ available_methods: │ │ │
│ - "password" │ │ payload: │
│ - "oidc-google" ◀─────────┼────┤ provider: "standard" │
│ │ │ issuer: ... │
│ success_conditions: │ │ userinfo_mapping_rules │
│ oidc-google.success >= 1 │ │ │
└─────────────────────────────┘ └─────────────────────────────┘
紐づけルール:
- Client → Federation:
extension.available_federations[].sso_providerで利用可能なFederation Configurationを指定 - Policy → Federation:
available_methodsにoidc-{sso_provider}形式でFederation Configurationを参照 - auto_selected:
trueの場合、認証画面でこのFederationが自動選択される
設定ファイル構造
federation/oidc/external-idp.json
{
"id": "dc000822-a7ca-47b9-aea2-f81e2772b037",
"type": "oidc",
"sso_provider": "external-idp",
"payload": {
"issuer": "${EXTERNAL_IDP_ISSUER}",
"issuer_name": "external-idp",
"type": "oauth-extension",
"provider": "oauth-extension",
"authorization_endpoint": "${EXTERNAL_IDP_AUTHORIZATION_ENDPOINT}",
"token_endpoint": "${EXTERNAL_IDP_TOKEN_ENDPOINT}",
"userinfo_endpoint": "${EXTERNAL_IDP_USERINFO_ENDPOINT}",
"client_id": "${EXTERNAL_IDP_CLIENT_ID}",
"client_secret": "${EXTERNAL_IDP_CLIENT_SECRET}",
"client_authentication_type": "client_secret_post",
"redirect_uri": "${IDP_SERVER_URL}/${TENANT_ID}/v1/authorizations/federations/oidc/callback",
"scopes_supported": [
"openid",
"profile",
"email"
],
"userinfo_mapping_rules": [
{
"from": "$.sub",
"to": "external_user_id"
},
{
"from": "$.name",
"to": "name"
},
{
"from": "$.email",
"to": "email"
}
],
"access_token_expires_in": 300,
"refresh_token_expires_in": 1800,
"store_credentials": true
}
}