View a markdown version of this page

認証情報プロバイダーを設定する - Amazon Bedrock AgentCore

認証情報プロバイダーを設定する

AgentCore Identity のリソース認証情報プロバイダーは、エージェント、ID プロバイダー、リソースサーバー間の複雑な関係を管理するインテリジェントな仲介として機能します。各プロバイダーは、特定のサービスまたは ID システムに必要な特定のエンドポイント設定をカプセル化します。このサービスは、Google、GitHub、Slack、Salesforce などの一般的なサービス用の組み込みプロバイダーを提供し、開発作業を削減するために認可サーバーエンドポイントとプロバイダー固有のパラメータが事前設定されています。AgentCore Identity は、OAuth2 互換リソースサーバーと連携するように調整できる設定可能な OAuth2-compatible 認証情報プロバイダーを通じてカスタム設定をサポートします。OAuth2 認証情報プロバイダーの制限については、AgentCore Identity Service Quotas」を参照してください。

リソース認証情報プロバイダーはトークンボールトと深く統合され、シームレスな認証情報ライフサイクル管理を提供します。エージェントがリソースへのアクセスをリクエストすると、プロバイダーは認証フローを処理し、結果の認証情報をトークンボールトに保存し、必要なアクセストークンをエージェントに提供します。

OAuth 2.0 認証情報プロバイダーの作成

AgentCore Identity のプロバイダー設定は、さまざまなリソースと認証システムを使用した認証情報管理に必要な基本パラメータを定義します。

AgentCore CLI を使用している場合は、 agentcore add credential コマンドを使用して OAuth 2.0 認証情報プロバイダーを作成できます。

agentcore add credential --type oauth \ --name github-provider \ --discovery-url https://your-idp/.well-known/openid-configuration \ --client-id your-github-client-id \ --client-secret your-github-client-secret \ --scopes repo,user

CLI は認証情報設定を に保存agentcore/agentcore.jsonし、機密値 (クライアント ID とクライアントシークレット) を に保存しますagentcore/.env.local

または、Secrets Manager に既に保存されているクライアントシークレットへの参照を指定して、独自のシー AWS クレットを取得することもできます。

aws bedrock-agentcore-control create-oauth2-credential-provider \ --name "github-provider" \ --credential-provider-vendor "GithubOauth2" \ --oauth2-provider-config-input '{ "githubOauth2ProviderConfig": { "clientId": "your-github-client-id", "clientSecretSource": "EXTERNAL", "clientSecretConfig": { "secretId": "arn:aws:secretsmanager:us-east-1:123456789012:secret:my-secret", "jsonKey": "clientSecret" } } }' \ --region us-east-1

または、AgentCore SDK を使用して OAuth 2.0 認証情報プロバイダーをプログラムで設定することもできます。次の例では、GitHub のプロバイダーを設定します。

from bedrock_agentcore.services.identity import IdentityClient identity_client = IdentityClient("us-east-1") github_provider = identity_client.create_oauth2_credential_provider({ "name": "github-provider", "credentialProviderVendor": "GithubOauth2", "oauth2ProviderConfigInput": { "githubOauth2ProviderConfig": { "clientId": "your-github-client-id", "clientSecret": "your-github-client-secret" } } })

OAuth 2.0 認証情報プロバイダーでon-behalf-of (OBO) トークン交換を設定するには、プロバイダー設定onBehalfOfTokenExchangeConfigに を追加します。サポートされているモード、パラメータ、および例については、「トークン交換On-behalf-of」を参照してください。

API キー認証情報プロバイダーの作成

OAuth ではなく API キーを認証に使用するサービスの場合、AgentCore Identity はエージェントのキーを安全に保存および取得します。API キー認証情報プロバイダーの制限については、AgentCore Identity Service Quotas」を参照してください。

AgentCore CLI を使用している場合は、1 つのコマンドで API キーを保存できます。

agentcore add credential --name your-service-name --api-key your-api-key

または、Secrets Manager に既に保存されている API キーへの参照を指定して、独自の AWS シークレットを取得することもできます。

aws bedrock-agentcore-control create-api-key-credential-provider \ --name "your-service-name" \ --api-key-secret-source EXTERNAL \ --api-key-secret-config secretId=arn:aws:secretsmanager:us-east-1:123456789012:secret:my-secret,jsonKey=api_key \ --region us-east-1

または、AgentCore SDK を使用して API キーをプログラムで保存することもできます。

from bedrock_agentcore.services.identity import IdentityClient identity_client= IdentityClient("us-east-1") apikey_provider= identity_client.create_api_key_credential_provider({ "name": "your-service-name", "apiKey": "your-api-key" })

支払い認証情報プロバイダーの作成

Coinbase CDP や Stripe Privy などの支払いプロセッサ認証情報を使用するサービスの場合、AgentCore Identity は関連する API キー、アプリシークレット、ウォレット/認可シークレットを Secrets Manager に安全に保存し、エージェントに ARNs のみを表示します。支払い認証情報プロバイダーの制限については、AgentCore Identity Service Quotas」を参照してください。

支払い認証情報プロバイダーは現在、 CoinbaseCDPと の 2 つのベンダーをサポートしていますStripePrivy。選択した に一致する設定ブロックproviderConfigurationInputを に 1 つだけcredentialProviderVendor指定します。または、Secrets Manager に既に保存されているシークレットへの参照を指定して、独自のシー AWS クレットを持ち込むこともできます。

AWS CLI

次の例では、Coinbase CDP の支払い認証情報プロバイダーを作成します。

aws bedrock-agentcore-control create-payment-credential-provider \ --name "coinbase-provider" \ --credential-provider-vendor CoinbaseCDP \ --provider-configuration-input '{ "coinbaseCdpConfiguration": { "apiKeyId": "your-coinbase-api-key-id", "apiKeySecret": "your-coinbase-api-key-secret", "walletSecret": "your-coinbase-wallet-secret" } }' \ --region us-east-1

次の例では、 AWS Secrets Manager に保存されているシークレットを使用して Coinbase CDP 支払い認証情報プロバイダーを作成します。

aws bedrock-agentcore-control create-payment-credential-provider \ --name "coinbase-provider" \ --credential-provider-vendor "CoinbaseCDP" \ --provider-configuration-input '{ "coinbaseCdpConfiguration": { "apiKeyId": "your-coinbase-api-key-id", "apiKeySecretSource": "EXTERNAL", "apiKeySecretConfig": { "secretId": "arn:aws:secretsmanager:us-east-1:123456789012:secret:my-api-secret", "jsonKey": "apiKeySecret" }, "walletSecretSource": "EXTERNAL", "walletSecretConfig": { "secretId": "arn:aws:secretsmanager:us-east-1:123456789012:secret:my-wallet-secret", "jsonKey": "walletSecret" } } }' \ --region us-east-1

次の例では、Stripe Privy の支払い認証情報プロバイダーを作成します。

aws bedrock-agentcore-control create-payment-credential-provider \ --name "stripe-privy-provider" \ --credential-provider-vendor StripePrivy \ --provider-configuration-input '{ "stripePrivyConfiguration": { "appId": "your-stripe-privy-app-id", "appSecret": "your-stripe-privy-app-secret", "authorizationPrivateKey": "your-stripe-privy-authorization-private-key", "authorizationId": "your-stripe-privy-authorization-id" } }' \ --region us-east-1

次の例では、 AWS Secrets Manager に保存されているシークレットを使用して Stripe Privy 支払い認証情報プロバイダーを作成します。

aws bedrock-agentcore-control create-payment-credential-provider \ --name "stripe-privy-provider" \ --credential-provider-vendor "StripePrivy" \ --provider-configuration-input '{ "stripePrivyConfiguration": { "appId": "your-stripe-privy-app-id", "appSecretSource": "EXTERNAL", "appSecretConfig": { "secretId": "arn:aws:secretsmanager:us-east-1:123456789012:secret:my-app-secret", "jsonKey": "appSecret" }, "authorizationPrivateKeySource": "EXTERNAL", "authorizationPrivateKeyConfig": { "secretId": "arn:aws:secretsmanager:us-east-1:123456789012:secret:my-auth-key-secret", "jsonKey": "authorizationPrivateKey" }, "authorizationId": "your-stripe-privy-authorization-id" } }' \ --region us-east-1
AWS SDK

次の例では、Coinbase CDP のプロバイダーを設定します。

import boto3 client = boto3.client("bedrock-agentcore-control", region_name="us-east-1") coinbase_provider = client.create_payment_credential_provider( name="coinbase-provider", credentialProviderVendor="CoinbaseCDP", providerConfigurationInput={ "coinbaseCdpConfiguration": { "apiKeyId": "your-coinbase-api-key-id", "apiKeySecret": "your-coinbase-api-key-secret", "walletSecret": "your-coinbase-wallet-secret" } } )

次の例では、 AWS Secrets Manager に保存されているシークレットを使用して Coinbase CDP プロバイダーを設定します。

import boto3 client = boto3.client("bedrock-agentcore-control", region_name="us-east-1") coinbase_provider = client.create_payment_credential_provider( name="coinbase-provider", credentialProviderVendor="CoinbaseCDP", providerConfigurationInput={ "coinbaseCdpConfiguration": { "apiKeyId": "your-coinbase-api-key-id", "apiKeySecretSource": "EXTERNAL", "apiKeySecretConfig": { "secretId": "arn:aws:secretsmanager:us-east-1:123456789012:secret:my-api-secret", "jsonKey": "apiKeySecret" }, "walletSecretSource": "EXTERNAL", "walletSecretConfig": { "secretId": "arn:aws:secretsmanager:us-east-1:123456789012:secret:my-wallet-secret", "jsonKey": "walletSecret" } } } )

次の例では、Stripe Privy のプロバイダーを設定します。

import boto3 client = boto3.client("bedrock-agentcore-control", region_name="us-east-1") stripe_privy_provider = client.create_payment_credential_provider( name="stripe-privy-provider", credentialProviderVendor="StripePrivy", providerConfigurationInput={ "stripePrivyConfiguration": { "appId": "your-stripe-privy-app-id", "appSecret": "your-stripe-privy-app-secret", "authorizationPrivateKey": "your-stripe-privy-authorization-private-key", "authorizationId": "your-stripe-privy-authorization-id" } } )

次の例では、 AWS Secrets Manager に保存されているシークレットを使用して Stripe Privy プロバイダーを設定します。

import boto3 client = boto3.client("bedrock-agentcore-control", region_name="us-east-1") stripe_privy_provider = client.create_payment_credential_provider( name="stripe-privy-provider", credentialProviderVendor="StripePrivy", providerConfigurationInput={ "stripePrivyConfiguration": { "appId": "your-stripe-privy-app-id", "appSecretSource": "EXTERNAL", "appSecretConfig": { "secretId": "arn:aws:secretsmanager:us-east-1:123456789012:secret:my-app-secret", "jsonKey": "appSecret" }, "authorizationPrivateKeySource": "EXTERNAL", "authorizationPrivateKeyConfig": { "secretId": "arn:aws:secretsmanager:us-east-1:123456789012:secret:my-auth-key-secret", "jsonKey": "authorizationPrivateKey" }, "authorizationId": "your-stripe-privy-authorization-id" } } )
AgentCore SDK

次の例では、Coinbase CDP のプロバイダーを設定します。

from bedrock_agentcore.services.identity import IdentityClient identity_client = IdentityClient("us-east-1") coinbase_provider = identity_client.create_payment_credential_provider( name="coinbase-provider", credential_provider_vendor="CoinbaseCDP", provider_configuration_input={ "coinbaseCdpConfiguration": { "apiKeyId": "your-coinbase-api-key-id", "apiKeySecret": "your-coinbase-api-key-secret", "walletSecret": "your-coinbase-wallet-secret" } } )

次の例では、 AWS Secrets Manager に保存されているシークレットを使用して Coinbase CDP プロバイダーを設定します。

from bedrock_agentcore.services.identity import IdentityClient identity_client = IdentityClient("us-east-1") coinbase_provider = identity_client.create_payment_credential_provider( name="coinbase-provider", credential_provider_vendor="CoinbaseCDP", provider_configuration_input={ "coinbaseCdpConfiguration": { "apiKeyId": "your-coinbase-api-key-id", "apiKeySecretSource": "EXTERNAL", "apiKeySecretConfig": { "secretId": "arn:aws:secretsmanager:us-east-1:123456789012:secret:my-api-secret", "jsonKey": "apiKeySecret" }, "walletSecretSource": "EXTERNAL", "walletSecretConfig": { "secretId": "arn:aws:secretsmanager:us-east-1:123456789012:secret:my-wallet-secret", "jsonKey": "walletSecret" } } } )

次の例では、Stripe Privy のプロバイダーを設定します。

from bedrock_agentcore.services.identity import IdentityClient identity_client = IdentityClient("us-east-1") stripe_privy_provider = identity_client.create_payment_credential_provider( name="stripe-privy-provider", credential_provider_vendor="StripePrivy", provider_configuration_input={ "stripePrivyConfiguration": { "appId": "your-stripe-privy-app-id", "appSecret": "your-stripe-privy-app-secret", "authorizationPrivateKey": "your-stripe-privy-authorization-private-key", "authorizationId": "your-stripe-privy-authorization-id" } } )

次の例では、 AWS Secrets Manager に保存されているシークレットを使用して Stripe Privy プロバイダーを設定します。

from bedrock_agentcore.services.identity import IdentityClient identity_client = IdentityClient("us-east-1") stripe_privy_provider = identity_client.create_payment_credential_provider( name="stripe-privy-provider", credential_provider_vendor="StripePrivy", provider_configuration_input={ "stripePrivyConfiguration": { "appId": "your-stripe-privy-app-id", "appSecretSource": "EXTERNAL", "appSecretConfig": { "secretId": "arn:aws:secretsmanager:us-east-1:123456789012:secret:my-app-secret", "jsonKey": "appSecret" }, "authorizationPrivateKeySource": "EXTERNAL", "authorizationPrivateKeyConfig": { "secretId": "arn:aws:secretsmanager:us-east-1:123456789012:secret:my-auth-key-secret", "jsonKey": "authorizationPrivateKey" }, "authorizationId": "your-stripe-privy-authorization-id" } } )