Client設定ガイド(開発者向け)
📍 このドキュメントの位置づけ
対象読者: Phase 1(how-to 01-05)完了済みの開発者
このドキュメントで学べること:
- 本番運用に向けた詳細なClient設定
- ユースケース別の設定パターン
- 高度な機能(暗号化、CIBA、Federation等)
- セキュリティとパフォーマンスのベストプラクティス
How-toガイドとの違い:
| ドキュメント | 目的 | 内容 |
|---|---|---|
| How-to | 最小 構成で動かす | 実践的な手順(動作確認重視) |
| Developer Guide | 本番設定を理解する | 詳細仕様と設計パターン |
前提知識:
- how-to-03: クライアント登録完了
- OAuth 2.0/OpenID Connectの基礎理解
🧭 Client概念の理解
Client(クライアント)は、OAuth 2.0/OIDCプロトコルを使用してリソースにアクセスするアプリケーションです。
クライアントには以下の2種類があります:
- Confidential Client(機密クライアント):
client_secretを安全に保管できる(例:サーバーサイドWebアプリ) - Public Client(公開クライアント):
client_secretを保管できない(例:SPA、モバイルアプリ)
詳細な説明は専用コンセプトドキュメントを参照:
- 📖 Concept 19: Client - Client種別、認証方法の詳細、Tenant-Client-User関係図、セキュリティベストプラクティス
📖 API仕様リファレンス
Client登録・更新のAPI詳細仕様(リ クエスト/レスポンススキーマ、全パラメータ説明)は、OpenAPI仕様書を参照してください。
📖 OpenAPI仕様書:
- swagger-cp-client-ja.yaml - クライアント管理API仕様
🎯 シナリオ別設定例
実際のユースケースに応じたClient設定例を紹介します。
| # | シナリオ | ユースケース | 主なポイント | 詳細 |
|---|---|---|---|---|
| 1 | Webアプリケーション(標準) | サーバーサイドアプリがユーザー認証を行い、バックエンドでトークンを安全に管理する | • client_secret_basic • Authorization Code Flow • Refresh Token | 詳細 |
| 2 | SPA(Single Page App) | ブラウザのみで動作するアプリがユーザー認証を行い、短命トークンで安全性を確保する | • PKCE必須 • token_auth: none • 短いAccess Token | 詳細 |
| 3 | モバイルアプリ(iOS/Android) | モバイルユーザーが長期間(30日)ログインを維持し、アプリを快適に利用する | • PKCE必須 • カスタムURLスキーム • 長期Refresh Token | 詳細 |
| 4 | M2M(Machine-to-Machine) | バックエンドサービスがユーザー認証なしで他のサービスのAPIにアクセスする | • Client Credentials Flow • redirect_uri不要 • カスタムスコープ | 詳細 |
| 5 | 金融グレード(FAPI) | 銀行システムが最高レベルのセキュリティでユーザー取引情報にアクセスする | • private_key_jwt / mTLS • 短いAccess Token • PAR必須 | 詳細 |
📋 シナリオ詳細設定
1. Webアプリケーション(標準)
要件:
- Authorization Code Flow
- client_secret使用
- Refresh Token対応
ユースケース: 一般的なサーバーサイドWebアプリケーション
設定JSON例を表示
{
"client_id": "web-app-client",
"client_secret": "your-secret-here",
"client_name": "My Web Application",
"redirect_uris": [
"https://app.example.com/callback",
"http://localhost:3000/callback"
],
"response_types": ["code"],
"grant_types": ["authorization_code", "refresh_token"],
"scope": "openid profile email",
"token_endpoint_auth_method": "client_secret_basic",
"application_type": "web",
"extension": {
"access_token_duration": 3600,
"refresh_token_duration": 86400
}
}
設定ポイント:
token_endpoint_auth_method: "client_secret_basic": HTTP Basic認証(最も一般的)grant_types:authorization_code,refresh_tokenの2つextension.access_token_duration: 3600: 1時間(標準的)
2. SPA(Single Page App)
要件:
- Authorization Code Flow + PKCE
- client_secret不要
- 短いトークン有効期限
ユースケース: React/Vue/Angularなどのブラウザアプリ
設定JSON例を表示
{
"client_id": "spa-client",
"client_name": "My SPA Application",
"redirect_uris": [
"https://spa.example.com/callback",
"https://spa.example.com/silent-renew"
],
"response_types": ["code"],
"grant_types": ["authorization_code", "refresh_token"],
"scope": "openid profile email",
"token_endpoint_auth_method": "none",
"application_type": "web",
"extension": {
"access_token_duration": 900,
"refresh_token_duration": 3600
}
}
設定ポイント:
token_endpoint_auth_method: "none": Public Client(PKCE必須)extension.access_token_duration: 900: 15分(セキュリティ重視)extension.refresh_token_duration: 3600: 1時間(短め)
重要: 実装時にcode_challenge/code_verifierを必ず使用
3. モバイルアプリ(iOS/Android )
要件:
- Authorization Code Flow + PKCE
- カスタムURLスキーム
- 長期間のRefresh Token
ユースケース: iOSアプリ、Androidアプリ
設定JSON例を表示
{
"client_id": "mobile-app-client",
"client_name": "My Mobile App",
"redirect_uris": [
"com.example.myapp://callback",
"https://app.example.com/mobile-callback"
],
"response_types": ["code"],
"grant_types": ["authorization_code", "refresh_token"],
"scope": "openid profile email offline_access",
"token_endpoint_auth_method": "none",
"application_type": "native",
"extension": {
"access_token_duration": 3600,
"refresh_token_duration": 2592000
}
}
設定ポイント:
application_type: "native": モバイルアプリ専用redirect_uris: カスタムURLスキーム(com.example.myapp://)extension.refresh_token_duration: 2592000: 30日間scope:offline_accessで長期トークン取得
4. M2M(Machine-to-Machine)
要件:
- Client Credentials Flow
- ユーザー認証不要
- サービス間認証
ユースケース: バックエンドサービス、APIゲートウェイ
設定JSON例を表示
{
"client_id": "backend-service",
"client_secret": "service-secret-here",
"client_name": "Backend Service",
"redirect_uris": [],
"response_types": [],
"grant_types": ["client_credentials"],
"scope": "api:read api:write",
"token_endpoint_auth_method": "client_secret_basic",
"application_type": "web"
}
設定ポイント:
grant_types: ["client_credentials"]: M2M専用redirect_uris: []: リダイレクト不要response_types: []: 認可コード不要scope: カスタムスコープ(api:read,api:write等)
5. 金融グレード(FAPI)
要件:
- FAPI 1.0 Advanced Profile準拠
- 強力なクライアント認証(Private Key JWT, mTLS)
- PAR(Pushed Authorization Request)
ユースケース: オンラインバンキング、証券取引
設定JSON例を表示
{
"client_id": "banking-client",
"client_name": "Online Banking System",
"redirect_uris": [
"https://banking.example.com/callback"
],
"response_types": ["code"],
"grant_types": ["authorization_code", "refresh_token"],
"scope": "openid profile email openbanking:accounts openbanking:payments",
"token_endpoint_auth_method": "private_key_jwt",
"application_type": "web",
"jwks_uri": "https://banking.example.com/.well-known/jwks.json",
"require_pushed_authorization_requests": true,
"extension": {
"access_token_duration": 600,
"refresh_token_duration": 3600
}
}
設定ポイント:
token_endpoint_auth_method: "private_key_jwt": 秘密鍵署名(最高セキュリティ)jwks_uri: クライアント公開鍵の配置場所require_pushed_authorization_requests: true: PAR必須extension.access_token_duration: 600: 10分(短い有効期限)
JARM(JWT Secured Authorization Response Mode):
FAPI Advancedクライアントでは、認可レスポンスをJWTで保護する response_mode を使用できます。
{
"response_mode": "jwt"
}
response_mode | 説明 |
|---|---|
jwt | 認可レスポンスをJWT形式で返却(デフォルトの配送方法を使用) |
query.jwt | クエリパラメータでJWT形式の認可レスポンスを返却 |
fragment.jwt | フラグメントでJWT形式の認可レスポンスを返却 |
JARMの利点:
- 認可レスポンスの改ざん防止(署名付き)
- 認可レスポンスの盗聴防止(暗号化可能)
- FAPI 1.0 Advanced Profile準拠の要件
FAPI準拠の利点:
- 金融機関レベルのセキュリティ
- 国際標準への準拠
- 監査対応の容易さ
⚙️ 高度な設定
Extension設定の詳細
extensionオブジェクトには、idp-server固有の拡張設定を含めます。
トークン有効期限のカスタマイズ
{
"extension": {
"access_token_duration": 7200,
"refresh_token_duration": 172800,
"id_token_duration": 1800,
"refresh_token_strategy": "EXTENDS",
"rotate_refresh_token": false
}
}
デフォルト値: Tenant設定の値を継承
| フィールド | 説明 | 設定値 |
|---|---|---|
access_token_duration | アクセストークンの有効期限(秒) | 正の整数 |
refresh_token_duration | リフレッシュトークンの有効期限(秒) | 正の整数 |
id_token_duration | IDトークンの有効期限(秒) | 正の整数 |
refresh_token_strategy | リフレッシュトークンの有効期限戦略 | "FIXED" / "EXTENDS" |
rotate_refresh_token | リフレッシュトークンのローテーション有無 | true / false |