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. 既存ユーザーを検索し、見つかればそれをベースに 3 を重ねる │ │