Tenant設定ガイド(開発者向け)
📍 このドキュメントの位置づけ
対象読者: Phase 1(how-to 01-05)完了済みの開発者
このドキュメントで学べること:
- 本番運用に向けた詳細なTenant設定
- ユースケース別の設定パターン
- 高度な機能(Extension、カスタムスコープ、カスタムクレーム)
- セキュリティとパフォーマンスのベストプラクティス
How-toガイドとの違い:
| ドキュメント | 目的 | 内容 |
|---|---|---|
| How-to | 最小構成で動かす | 実践的な手順(動作確認重視) |
| Developer Guide | 本番設定を理解する | 詳細仕様と設計パターン |
前提知識:
- how-to-01: 組織初期化完了
- how-to-02: OAuth/OIDC認証の最小設定完了
- OAuth 2.0/OpenID Connectの基礎理解
🧭 Tenantアーキテクチャの理解
Tenantとは
Tenant(テナント)は、マルチテナント環境における完全に独立した認証・認可ドメインです。
Organization vs Tenant
┌─────────────────────────────────────────────────────────┐
│ Organization (企業A) │
│ │
│ ┌──────────────────┐ ┌──────────────────┐ │
│ │ Organizer Tenant │ │ Public Tenant │ │
│ │ (組織管理用) │ │ (アプリ用) │ │
│ ├──────────────────┤ ├──────────────────┤ │
│ │ - 組織管理者 │ │ - Client 1 │ │
│ │ - テナント管理 │ │ - Client 2 │ │
│ │ │ │ - Users │ │
│ └──────────────────┘ └──────────────────┘ │
└─────────────────────────────────────────────────────────┘
データ分離の仕組み
各Tenantで完全に分離されるもの:
- ユーザーデータ: 認証情報、プロファイル
- クライアント設定: OAuth/OIDCクライアント
- 認証ポリシー: パスワードポリシー、MFA設定
- トークン設定: 有効期限、署名鍵
- セキュリティイベントログ: 監査ログ
テナント種別
| 種別 | 説明 | 作成方法 | 用途 |
|---|---|---|---|
ADMIN | システム管理用テナ ント | システム初期化時に自動作成 | システム管理・初期設定用 |
ORGANIZER | 組織管理用テナント | 組織作成(Onboarding API)時に自動作成 | 組織管理者の管理操作用 |
PUBLIC | アプリケーション用テナント | 組織レベルAPIで作成 | 通常のアプリケーション用 |
実装リファレンス:
ADMIN: IdpServerStarterContextCreator.java:78ORGANIZER: OnboardingContextCreator.java:82PUBLIC: TenantManagementRegistrationContextCreator.java:68
重要: 組織レベルAPI(POST /v1/management/organizations/{org-id}/tenants)で作成されるテナントは常にtype: "PUBLIC"です。ADMINとORGANIZERは手動で作成できません。
📖 API仕様リファレンス
テナント作成・更新のAPI詳細仕様(リクエスト/レスポンススキーマ、全パラメータ説明)は、OpenAPI仕様書を参照してください。
📖 OpenAPI仕様書:
- swagger-cp-tenant-ja.yaml - テナント管理API仕様
🎯 シナリオ別設定例
実際のユースケースに応じた認可サーバー設定例を紹介します。
| # | シナリオ | ユースケース | 主なポイント | 詳細 |
|---|---|---|---|---|
| 1 | Webアプリケーション(標準) | ユーザーがWebブラウザから安全にログインし、セッション中は再認証なしでサービスを利用する | • Opaque Token • Access Token: 30分 • Refresh Token: 1時間 | 詳細 |
| 2 | モバイルアプリ(PKCE) | モバイルユーザーが再ログインなしで長期間(30日)アプリを利用し続ける | • PKCE必須 • 長期Refresh Token(30日) • EXTENDS戦略 | 詳細 |
| 3 | 金融グレード(FAPI) | 銀行顧客が口座・取引情報に安全にアクセスし、厳格なセキュリティ基準を満たす | • Private Key JWT / mTLS • Pairwise Subject • Access Token: 10分 | 詳細 |
| 4 | SaaS型マルチテナント | 企業ユーザーが所属組織・部署情報を含むトークンでSaaSサ ービスにアクセスする | • JWT Token • カスタムクレーム • M2M通信対応 | 詳細 |
📋 シナリオ詳細設定
1. Webアプリケーション向け(標準)
要件:
- Authorization Code Flow
- Refresh Token使用
- Access Token: 30分
- Refresh Token: 1時間
ユースケース: 一般的なWebアプリケーション、SPA
設定JSON例を表示
{
"tenant": {
"id": "web-app-tenant",
"name": "Web Application Tenant",
"domain": "https://app.example.com",
"authorization_provider": "idp-server"
},
"authorization_server": {
"issuer": "https://app.example.com/web-app-tenant",
"authorization_endpoint": "https://app.example.com/web-app-tenant/v1/authorizations",
"token_endpoint": "https://app.example.com/web-app-tenant/v1/tokens",
"userinfo_endpoint": "https://app.example.com/web-app-tenant/v1/userinfo",
"jwks_uri": "https://app.example.com/web-app-tenant/v1/jwks",
"scopes_supported": ["openid", "profile", "email"],
"grant_types_supported": ["authorization_code", "refresh_token"],
"response_types_supported": ["code"],
"token_endpoint_auth_methods_supported": ["client_secret_post", "client_secret_basic"],
"extension": {
"access_token_type": "opaque",
"access_token_duration": 1800,
"refresh_token_duration": 3600,
"rotate_refresh_token": true
}
}
}
設定ポイント:
access_token_type: "opaque": 高速な不透明トークンrotate_refresh_token: true: セキュリティ向上のためリフレッシュトークンをローテーション
2. モバイルアプリ向け(PKCE対応)
要件:
- Authorization Code Flow + PKCE
- 長期間のRefresh Token(30日)
- カスタムスコープ(プッシュ通知、オフラインアクセス)
ユースケース: iOS/Androidアプリ、ネイティブアプリ
設定JSON例を表示
{
"tenant": {
"id": "mobile-app-tenant",
"name": "Mobile Application Tenant",
"domain": "https://mobile.example.com",
"authorization_provider": "idp-server"
},
"authorization_server": {
"issuer": "https://mobile.example.com/mobile-app-tenant",
"authorization_endpoint": "https://mobile.example.com/mobile-app-tenant/v1/authorizations",
"token_endpoint": "https://mobile.example.com/mobile-app-tenant/v1/tokens",
"userinfo_endpoint": "https://mobile.example.com/mobile-app-tenant/v1/userinfo",
"jwks_uri": "https://mobile.example.com/mobile-app-tenant/v1/jwks",
"scopes_supported": [
"openid",
"profile",
"email",
"offline_access",
"notifications:push"
],
"grant_types_supported": ["authorization_code", "refresh_token"],
"response_types_supported": ["code"],
"token_endpoint_auth_methods_supported": ["none"],
"extension": {
"access_token_type": "opaque",
"access_token_duration": 3600,
"refresh_token_duration": 2592000,
"rotate_refresh_token": true,
"refresh_token_strategy": "EXTENDS"
}
}
}
設定ポイント:
token_endpoint_auth_methods_supported: ["none"]: PKCE専用(Client Secretなし)refresh_token_duration: 2592000: 30日間の長期トークンrefresh_token_strategy: "EXTENDS": リフレッシュの度にトークン有効期限を延長(ユーザー体験向上)
3. 金融グレード(FAPI準拠)
要件:
- FAPI 1.0 Advanced Profile準拠
- 強力なクライアント認証(Private Key JWT, mTLS)
- Pairwise Subject(プライバシー保護)
- カスタムスコープ(OpenBanking)
ユースケース: オンラインバンキング、金融API、 機密データアクセス
設定JSON例を表示
{
"tenant": {
"id": "banking-tenant",
"name": "Online Banking Platform",
"domain": "https://banking.example.com",
"authorization_provider": "idp-server"
},
"session_config": {
"use_secure_cookie": true,
"cookie_same_site": "Strict",
"switch_policy": "STRICT"
},
"cors_config": {
"allow_origins": ["https://banking.example.com"]
},
"authorization_server": {
"issuer": "https://banking.example.com/banking-tenant",
"authorization_endpoint": "https://banking.example.com/banking-tenant/v1/authorizations",
"token_endpoint": "https://banking.example.com/banking-tenant/v1/tokens",
"userinfo_endpoint": "https://banking.example.com/banking-tenant/v1/userinfo",
"jwks_uri": "https://banking.example.com/banking-tenant/v1/jwks",
"scopes_supported": [
"openid",
"profile",
"email",
"openbanking:accounts",
"openbanking:transactions",
"openbanking:payments"
],
"grant_types_supported": ["authorization_code", "refresh_token"],
"response_types_supported": ["code"],
"response_modes_supported": ["query", "jwt"],
"token_endpoint_auth_methods_supported": [
"private_key_jwt",
"tls_client_auth"
],
"subject_types_supported": ["pairwise"],
"extension": {
"access_token_type": "jwt",
"access_token_duration": 600,
"refresh_token_duration": 3600,
"authorization_code_valid_duration": 300,
"fapi_baseline_scopes": ["openbanking:accounts", "openbanking:transactions"],
"fapi_advance_scopes": ["openbanking:payments"],
"id_token_strict_mode": true
}
}
}
設定ポイント:
token_endpoint_auth_methods_supported:private_key_jwt,tls_client_authのみ許可subject_types_supported: ["pairwise"]: ユーザー識別子を分離(プライバシー保護)access_token_type: "jwt": JWT形式で署名検証可能access_token_duration: 600: 10分の短い有効期限(セキュリティ向上)fapi_baseline_scopes/fapi_advance_scopes: FAPI検 証スコープswitch_policy: "STRICT": 別ユーザー認証を拒否(ログアウト必須)
FAPI準拠の利点:
- 金融機関レベルのセキュリティ
- 国際標準への準拠
- 監査対応の容易さ
4. SaaS型マルチテナント
要件:
- 複数企業の従業員が利用
- カスタムクレーム(企業ID、部署、権限)
- JWT形式のAccess Token
- M2M通信(Client Credentials Grant)
ユースケース: B2B SaaS、企業向けプラットフォーム
設定JSON例を表示
{
"tenant": {
"id": "saas-tenant",
"name": "SaaS Platform Tenant",
"domain": "https://saas.example.com",
"authorization_provider": "idp-server"
},
"authorization_server": {
"issuer": "https://saas.example.com/saas-tenant",
"authorization_endpoint": "https://saas.example.com/saas-tenant/v1/authorizations",
"token_endpoint": "https://saas.example.com/saas-tenant/v1/tokens",
"userinfo_endpoint": "https://saas.example.com/saas-tenant/v1/userinfo",
"jwks_uri": "https://saas.example.com/saas-tenant/v1/jwks",
"scopes_supported": [
"openid",
"profile",
"email",
"claims:organization_id",
"claims:department",
"claims:role"
],
"grant_types_supported": ["authorization_code", "refresh_token", "client_credentials"],
"response_types_supported": ["code"],
"extension": {
"access_token_type": "jwt",
"access_token_duration": 3600,
"custom_claims_scope_mapping": true
}
}
}
設定ポイント:
custom_claims_scope_mapping: true: カスタムクレームをスコープでマッピングclaims:organization_id,claims:department: 企業・部署情報をトークンに含めるgrant_types_supported:client_credentialsを追加(M2M通信)access_token_type: "jwt": クレーム情報をトークン内に含める
⚙️ 高度な設定
Extension設定の詳細
extension