Skip to content

OAuth 2.0 セキュア認証体系 ​

天枢AI-TokenHub は、完全なエンタープライズ向け OAuth 2.0 認証機能を提供し、安全なユーザー委任アクセスとサードパーティ統合をサポートしており、OAuth 2.0 標準仕様に完全準拠しています。

中核となる特長 ​

✨ 組み込みの OAuth 機能 ​

天枢AI-TokenHub は完全な OAuth 2.0 プロトコルスタックをネイティブにサポートしており、導入後すぐに利用できます:

  • 自動 Token リフレッシュ:トークンの有効期限前に自動でリフレッシュし、業務コードでの処理が不要
  • PKCE サポート:パブリッククライアントがクライアントシークレットなしで安全に認証可能
  • 動的クライアント登録:クライアント登録を自動で完了し、RFC 7591 標準に準拠
  • OAuth 自動検出:サーバー URL から認証エンドポイントを自動検出
  • Token のライフサイクル全体の管理:トークンの保存、照会、失効などの操作をサポート
  • エンタープライズセキュリティ:OAuth 2.0 のセキュリティベストプラクティスに準拠し、各種暗号化アルゴリズムをサポート

OAuth 認可フロー ​

天枢AI-TokenHub は、業界で最も安全かつ広く利用されている Authorization Code 認可コードフローを実装しています:

Client                  Tianshu AI-TokenHub                  Authorization Server
  │                             │                                   │
  ├─ Create MCP client config ──►│                                   │
  │                             │ Return authorization URL          │
  │                             │                                   │
  ├─ Redirect user to auth URL ─┼──────────────────────────────────►│
  │                             │                                   │ User logs in and authorizes
  │                             │◄──────────────────────────────────┤
  │                             │ Authorization callback            │
  │                             │                                   │
  │                             │ Request token                     │
  │                             │◄──────────────────────────────────┤ Return token
  │                             │                                   │
  │◄───────────────────────────┤ MCP client created, ready to call  │

設定方法 ​

基本的な OAuth 設定 ​

MCP クライアントを作成する際に OAuth 認証を設定します:

json
{
  "name": "authenticated-service",
  "connection_type": "http",
  "connection_string": "https://api.example.com/mcp",
  "auth_type": "oauth",
  "oauth_config": {
    "client_id": "your-client-id",
    "client_secret": "your-client-secret",
    "authorize_url": "https://auth.example.com/oauth/authorize",
    "token_url": "https://auth.example.com/oauth/token",
    "scopes": ["mcp:read", "mcp:write"]
  },
  "tools_to_execute": ["*"]
}

作成に成功すると以下が返されます:

json
{
  "status": "pending_oauth",
  "message": "OAuth authorization required",
  "oauth_config_id": "oauth_cfg_abc123",
  "authorize_url": "https://auth.example.com/oauth/authorize?client_id=...&state=xyz",
  "expires_at": "2026-01-24T12:30:00Z",
  "mcp_client_id": "mcp_client_abc123"
}

ユーザーを authorize_url にリダイレクトして認可を完了した後、完了インターフェースを呼び出します:

bash
curl -X POST https://ai-tokenhub.ai/api/mcp/client/mcp_client_abc123/complete-oauth

PKCE パブリッククライアントの設定 ​

クライアントシークレットを持たないアプリケーションでは、PKCE(Proof Key for Code Exchange)モードを使用できます:

json
{
  "name": "public-client-service",
  "connection_type": "http",
  "connection_string": "https://api.example.com/mcp",
  "auth_type": "oauth",
  "oauth_config": {
    "client_id": "your-public-client-id",
    "authorize_url": "https://auth.example.com/oauth/authorize",
    "token_url": "https://auth.example.com/oauth/token",
    "scopes": ["mcp:read"]
  },
  "tools_to_execute": ["*"]
}

天枢AI-TokenHub は PKCE コード検証子を自動的に生成・管理するため、追加設定は不要です。

動的クライアント登録 ​

OAuth サーバーが RFC 7591 をサポートしている場合、天枢AI-TokenHub はクライアントを自動登録できます:

json
{
  "name": "auto-registered-service",
  "connection_type": "http",
  "connection_string": "https://api.example.com/mcp",
  "auth_type": "oauth",
  "oauth_config": {
    "registration_url": "https://auth.example.com/oauth/register",
    "server_url": "https://api.example.com",
    "scopes": ["mcp:read", "mcp:write"]
  },
  "tools_to_execute": ["*"]
}

OAuth 自動検出 ​

天枢AI-TokenHub はサーバーのメタデータから OAuth エンドポイントを自動検出できます:

json
{
  "name": "discovered-service",
  "connection_type": "http",
  "connection_string": "https://api.example.com/mcp",
  "auth_type": "oauth",
  "oauth_config": {
    "client_id": "your-client-id",
    "server_url": "https://api.example.com",
    "scopes": ["mcp:read"]
  },
  "tools_to_execute": ["*"]
}

OAuth エンドポイントが明示的に指定されていない場合、システムは以下を自動的に確認します:

  • /.well-known/oauth-authorization-server (RFC 8414)
  • /.well-known/openid-configuration
  • サーバーの MCP メタデータ

Token の管理 ​

Token ステータスの照会 ​

bash
curl https://ai-tokenhub.ai/api/oauth/config/oauth_cfg_abc123/status

返却結果:

json
{
  "id": "oauth_cfg_abc123",
  "status": "authorized",
  "created_at": "2026-01-24T10:00:00Z",
  "expires_at": "2026-01-31T10:00:00Z",
  "token_id": "oauth_token_xyz",
  "token_expires_at": "2026-01-25T10:00:00Z",
  "token_scopes": ["mcp:read", "mcp:write"]
}

ステータスの説明 ​

ステータス説明
pendingユーザーがまだ認可を完了していない
authorizedToken が有効でアクティブな状態
failed認可に失敗、または Token が失効済み

自動 Token リフレッシュ ​

天枢AI-TokenHub は Token の有効期限を自動的に監視し、期限切れ前に自動でリフレッシュを完了するため、業務システムの介入なしにサービスの継続性を保証します。

適用シーン ​

  • サードパーティ統合:サードパーティアプリケーションにプラットフォームリソースへのアクセスを安全に認可
  • ユーザー委任アクセス:ユーザーが認可する安全なアクセスモードをサポート
  • 企業内システム統合:異なる業務システム間の安全な呼び出し
  • コンプライアンスシーン:OAuth 2.0 のセキュリティ標準への準拠が必要な業務シーン
  • 定期認可シーン:定期的な再認可が必要なセキュリティ上重要な業務