View a markdown version of this page

Set up outbound authorization for your gateway - Amazon Bedrock AgentCore

Set up outbound authorization for your gateway

Outbound authorization lets Amazon Bedrock AgentCore gateways securely access gateway targets on behalf of users that were authenticated and authorized during inbound authorization.

AgentCore Gateway supports the following types of outbound authorization:

  • No authorization (not recommended) – Some target types provide you the option to bypass outbound authorization. This less secure option is not recommended.

  • IAM-based outbound authorization – Use the gateway service role to authenticate access to the gateway target with AWS Signature Version 4 (Sig V4).

  • Caller IAM credentials – The gateway uses the caller’s IAM credentials to sign requests to the target. The gateway assumes a role on behalf of the caller using the Federated Access Service (FAS) and signs the outbound request with the caller’s identity. This is useful when the target service needs to authorize based on the original caller’s identity rather than the gateway service role.

  • OAuth – An open authorization framework that allows a client application to access resources. You can use OAuth with a built-in identity provider or with a custom one. For more information, see OAuth 2.0 . You can use the following types of OAuth authorization grants:

    • Client credentials grant – Machine-to-machine authentication (also known as 2-legged OAuth). The client application accesses resources on the application’s behalf, rather than on behalf of the user.

    • Authorization code grant – User-delegated access (also known as 3-legged OAuth). The user provides consent for the client application to access resources on behalf of the user.

    • Token exchange grant (On-behalf-of) – The gateway exchanges the inbound user’s access token for a new, scoped access token that targets a downstream resource. The exchanged token carries both the user’s identity and the agent’s identity, enabling downstream services to enforce fine-grained authorization at every hop without triggering additional consent flows. For more information, see On-behalf-of token exchange.

  • Token passthrough – The gateway passes the inbound authorization token directly to the target without modification. The target service is responsible for validating the token. Token passthrough requires an inbound type that carries a bearer token, either JWT inbound authorization or NONE. It isn’t available with AUTHENTICATE_ONLY, which uses SigV4 and carries no bearer token.

  • API key – Use the AgentCore service to generate an API key to authenticate access to the gateway target.

  • JWT-SVID (Preview) – The gateway presents a short-lived JSON Web Token SPIFFE Verifiable Identity Document (JWT-SVID), valid for 5 minutes by default, that proves the gateway’s identity from AWS Identity and Access Management (IAM). JWT-SVID is a JSON Web Token (JWT) in the format defined by the Secure Production Identity Framework for Everyone (SPIFFE). The target validates the token directly, so you don’t store or rotate API keys or OAuth credentials for it. The gateway must have IAM Agent and workload identity turned on.

The type of outbound authorization that you can set up is dependent on the gateway target type to which you authorize access:

Target type No authorization Gateway service role Caller IAM credentials OAuth (client credentials) OAuth (authorization code) OAuth (token exchange) Token passthrough API key JWT-SVID

API Gateway stage

Yes

Yes

No

No

No

No

No

Yes

No

Lambda function

No

Yes

No

No

No

No

No

No

No

MCP server

Yes

Yes

No

Yes

Yes

Yes

No

Yes

Yes

OpenAPI schema

Yes

Yes

No

Yes

Yes

Yes

No

Yes

Yes

Smithy schema

No

Yes

No

Yes

No

No

No

No

No

AgentCore Runtime (HTTP)

No

Yes

Yes

Yes

No

Yes

Yes

No

Yes

HTTP passthrough

Yes

Yes

Yes

Yes

No

Yes

Yes

Yes

Yes

Inference

No

Yes

No

No

No

No

No

Yes

No

Note

If you use an integration provider template as a target, review the supported authorization types for different templates at Built-in templates from integration providers as targets.

Before adding a target to your gateway, you must set up authorization for it through one of the supported methods.

Note

Whether the gateway service role gets these permissions automatically depends on how you create the target. When you add or edit a target in the AgentCore console, the console attaches the permissions for the target’s credential provider to the gateway’s service role, if the console created that role. The AgentCore CLI attaches them when you run agentcore deploy, only for targets declared in the project and only to a service role that the CLI created. Creating a gateway or target with the API, the AWS CLI, or an SDK doesn’t change the service role, so attach the permissions described in this topic yourself. For a target that signs requests with the gateway service role to a service outside AgentCore, such as an HTTP passthrough or MCP server target with IAM authorization, add the permissions that the target service requires to the gateway service role.

Select a topic to learn how to set up that type of authorization:

Set up IAM-based outbound authorization with a gateway service role

IAM-based outbound authorization lets you use the gateway service role’s IAM credentials to authorize with AWS Signature Version 4 (Sig V4) . This option lets the Amazon Bedrock AgentCore service authenticate to gateway targets on your gateway callers' behalf.

Additional configuration for MCP server and OpenAPI targets

When you use IAM-based outbound authorization with an MCP server or OpenAPI target, you must provide additional configuration for SigV4 signing. In the credentialProviderConfigurations , include an iamCredentialProvider with the following fields:

  • service (required) – The AWS service name used for SigV4 signing. For example, bedrock-agentcore for MCP servers hosted on Amazon Bedrock AgentCore.

  • region (optional) – The AWS Region for SigV4 signing. If you don’t specify a Region, the gateway uses its own Region.

For Lambda, API Gateway, and Smithy targets, do not include the iamCredentialProvider field. These target types only support the basic GATEWAY_IAM_ROLE configuration with credentialProviderType only. For more information about specifying the credential provider configuration, see AgentCore Gateway service role (IAM) authorization.

Security best practices for IAM-based outbound authorization

The gateway execution role is shared across all targets configured with GATEWAY_IAM_ROLE. Its permissions are the upper bound for what any authorized caller can exercise through the gateway. Follow these best practices to limit exposure:

  • Scope the execution role to minimum permissions – Grant only the permissions needed across all configured targets. Avoid broad Action or Resource wildcards.

  • Scope access with the gateway’s identity – If your gateway has IAM Agent and workload identity (Preview) turned on, scope access to the gateway’s identity with the aws:OriginIdentity/Subject condition key, so that other workloads that share the service role can’t reach the target. For more information, see Control access with agent and workload identity.

  • Use separate gateways for different trust boundaries – If targets have different sensitivity levels or serve different workloads, deploy them behind separate gateways with distinct execution roles.

  • Use the policy engine to restrict caller access – On shared gateways, use the policy engine to control which callers can invoke which targets, limiting the blast radius of any single caller’s permissions.

Set up outbound authorization with an OAuth client

To set up outbound authorization with an OAuth client, you use the AgentCore Identity service and specify client credentials that you receive from creating a client in either a built-in identity provider (see Provider setup and configuration or a custom identity provider.

To set up outbound authorization with an OAuth client

  1. Register your client application with a supported third-party provider.

  2. You’ll receive a client ID, client secret, and possibly other values that you’ll reference when you set up the outbound authorization.

  3. Follow one of the steps below, depending on your requirements:

  4. Take note of the generated credential ARN ( credentialProviderArn in the API) and the AWS Secrets Manager secret ARN ( secretArn in the API). You’ll use these values when you create your gateway target.

  5. (If AgentCore didn’t attach these permissions for you, as described in the note earlier in this topic) Attach the following identity-based policy to your gateway service role:

    { "Version": "2012-10-17", "Statement": [ { "Sid": "GetWorkloadAccessToken", "Effect": "Allow", "Action": [ "bedrock-agentcore:GetWorkloadAccessToken" ], "Resource": [ "arn:aws:bedrock-agentcore:us-east-1:123456789012:workload-identity-directory/default", "arn:aws:bedrock-agentcore:us-east-1:123456789012:workload-identity-directory/default/workload-identity/GatewayName-*" ] }, { "Sid": "GetResourceOauth2Token", "Effect": "Allow", "Action": [ "bedrock-agentcore:GetResourceOauth2Token" ], "Resource": [ "arn:aws:bedrock-agentcore:us-east-1:123456789012:workload-identity-directory/default", "arn:aws:bedrock-agentcore:us-east-1:123456789012:workload-identity-directory/default/workload-identity/GatewayName-*", "arn:aws:bedrock-agentcore:us-east-1:123456789012:token-vault/default", "arn:aws:bedrock-agentcore:us-east-1:123456789012:token-vault/default/oauth2credentialprovider/CredentialName" ] }, { "Sid": "GetSecretValue", "Effect": "Allow", "Action": [ "secretsmanager:GetSecretValue" ], "Resource": [ "arn:aws:secretsmanager:us-east-1:123456789012:secret:SecretId" ] } ] }

    Replace the values of the following fields:

    • In the GetWorkloadAccessToken and GetResourceOauth2Token statements, replace the GatewayName in the Resource list with the name of your gateway in lowercase.

      • If IAM Agent and workload identity (Preview) is turned on for this gateway, use –0— for the resource in the GetWorkloadAccessToken statement, because AgentCore doesn’t create an AgentCore Identity workload identity for it.

    • In the GetResourceOauth2Token statement, replace the last Resource entry with the ARN of the credential that you just generated. Keep all four resources. The call is authorized against the workload identity, the token vault, and the credential provider.

    • In the GetSecretValue statement, replace the value in the Resource list with the ARN of the AWS secret returned in the response when you generated the credential.

Examples for setting OAuth client authorization

The following examples show you how to set authorization through an OAuth client for your gateway target:

Example
AgentCore CLI
  1. Run the credential command inside an existing AgentCore project. If you don’t have one yet, create a project with agentcore create --name <ProjectName>.

    printf '%s' "$CLIENT_SECRET" | agentcore add credentials oauth \ --name oauth-credential-provider \ --vendor CustomOauth2 \ --discovery-url <DiscoveryUrl> \ --client-id <ClientId> \ --client-secret - agentcore deploy

    To use the interactive wizard instead, run agentcore add credentials oauth with no options.

AWS CLI
  1. aws bedrock-agentcore-control create-oauth2-credential-provider \ --name oauth-credential-provider \ --credential-provider-vendor CustomOauth2 \ --oauth2-provider-config-input '{ "customOauth2ProviderConfig": { "oauthDiscovery": { "discoveryUrl": "<DiscoveryUrl>" }, "clientId": "<ClientId>", "clientSecret": "<ClientSecret>" } }'
Boto3
  1. import boto3 client = boto3.client("bedrock-agentcore-control") client.create_oauth2_credential_provider( name="oauth-credential-provider", credentialProviderVendor="CustomOauth2", oauth2ProviderConfigInput={ "customOauth2ProviderConfig": { "oauthDiscovery": { "discoveryUrl": "<DiscoveryUrl>" }, "clientId": "<ClientId>", "clientSecret": "<ClientSecret>" } } )

Set up outbound authorization with an API key

To set up outbound authorization with an API key, you use the AgentCore Identity service and specify an API key that you receive from a supported identity provider.

To set up outbound authorization with an API key

  1. Register your client application with a supported third-party provider.

  2. Set up an API key for the provider’s service. Take note of the following values, which you’ll specify when you add the gateway target:

    • Credential location – Whether the API key should be placed in the header or as a query parameter.

    • Credential prefix – The prefix for the credential (ex. Bearer).

  3. Follow one of the steps below, depending on your requirements:

  4. Take note of the following values, which you’ll specify when you add the gateway target:

    • Credential provider ARN – An Amazon Resource Name (ARN) generated for the credential provider.

    • Name – The name you gave to the API key.

    • Secret ARN – An AWS Secrets Manager secret ARN generated for the API key.

  5. (If AgentCore didn’t attach these permissions for you, as described in the note earlier in this topic) Attach the following identity-based policy to your gateway service role:

    { "Version": "2012-10-17", "Statement": [ { "Sid": "GetWorkloadAccessToken", "Effect": "Allow", "Action": [ "bedrock-agentcore:GetWorkloadAccessToken" ], "Resource": [ "arn:aws:bedrock-agentcore:us-east-1:123456789012:workload-identity-directory/default", "arn:aws:bedrock-agentcore:us-east-1:123456789012:workload-identity-directory/default/workload-identity/GatewayName-*" ] }, { "Sid": "GetResourceApiKey", "Effect": "Allow", "Action": [ "bedrock-agentcore:GetResourceApiKey" ], "Resource": [ "arn:aws:bedrock-agentcore:us-east-1:123456789012:workload-identity-directory/default", "arn:aws:bedrock-agentcore:us-east-1:123456789012:workload-identity-directory/default/workload-identity/GatewayName-*", "arn:aws:bedrock-agentcore:us-east-1:123456789012:token-vault/default", "arn:aws:bedrock-agentcore:us-east-1:123456789012:token-vault/default/apikeycredentialprovider/Name" ] }, { "Sid": "GetSecretValue", "Effect": "Allow", "Action": [ "secretsmanager:GetSecretValue" ], "Resource": [ "arn:aws:secretsmanager:us-east-1:123456789012:secret:SecretId" ] } ] }

    Replace the values of the following fields:

    • In the GetWorkloadAccessToken and GetResourceApiKey statements, replace the GatewayName in the Resource list with the name of your gateway in lowercase.

      • If IAM Agent and workload identity (Preview) is turned on for this gateway, use –0— for the resource in the GetWorkloadAccessToken statement, because AgentCore doesn’t create an AgentCore Identity workload identity for it.

    • In the GetResourceApiKey statement, replace the last Resource entry with the ARN of the credential that you just generated. Keep all four resources. The call is authorized against the workload identity, the token vault, and the credential provider.

    • In the GetSecretValue statement, replace the value in the Resource list with the ARN of the AWS secret returned in the response when you generated the credential.

Examples for setting an API key

The following examples show you how to set an API key for your gateway target:

Example
AgentCore CLI
  1. Run the credential command inside an existing AgentCore project. If you don’t have one yet, create a project with agentcore create --name <ProjectName>.

    printf '%s' "$API_KEY" | agentcore add credentials api-key \ --name api-key-credential-provider \ --api-key - agentcore deploy

    To use the interactive wizard instead, run agentcore add credentials api-key with no options.

AWS CLI
  1. aws bedrock-agentcore-control create-api-key-credential-provider \ --name api-key-credential-provider \ --api-key <API_KEY_VALUE>
Boto3
  1. import boto3 client = boto3.client("bedrock-agentcore-control") client.create_api_key_credential_provider( name="api-key-credential-provider", apiKey="<API_KEY_VALUE>" )

Set up outbound authorization with JWT-SVID (Preview)

JWT-SVID outbound authorization lets the gateway authenticate to a target with its own identity instead of a stored credential. When the gateway calls the target, it requests a JWT-SVID for the audience configured on the target by calling the AWS Security Token Service (AWS STS) GetWebIdentityToken operation, and sends it in the Authorization header as a bearer token. The token’s subject (sub) is the gateway’s IAM Agent and workload identity, such as spiffe://111122223333.aws.internal/us-west-2/bedrock-agentcore/gateway/my-gateway/my-gateway-a1b2c3d4e5, and its audience (aud) is the value that you configured.

Use JWT-SVID for targets that can validate JWTs from your workload identity provider, such as services in a service mesh or your own APIs. The gateway doesn’t exchange the JWT-SVID for another token. If a target accepts only tokens from its own authorization server, use OAuth instead.

To set up outbound authorization with JWT-SVID . Turn on IAM Agent and workload identity (Preview) for the gateway. For more information, see Set up workload identity. . Allow the gateway service role to call sts:GetWebIdentityToken. If you are using a custom gateway service role, attach the following identity-based policy to your gateway service role:

+

{ "Version": "2012-10-17", "Statement": [ { "Sid": "GetJwtSvidForMyService", "Effect": "Allow", "Action": "sts:GetWebIdentityToken", "Resource": "*", "Condition": { "ForAllValues:StringEquals": { "sts:IdentityTokenAudience": ["<audience>"] }, "Null": { "sts:IdentityTokenAudience": "false" } } } ] }

+ . Configure the target to trust tokens from your workload identity provider. The target verifies the signature with the provider’s JSON Web Key Set (JWKS), and checks that aud matches its own audience and sub is the gateway’s identity. . When you add the target, specify JWT_SVID as the credential provider type and set the audience. By default, the token is valid for 5 minutes and is signed with RS256 (RSA with SHA-256). To sign with ES384 (ECDSA using the P-384 curve with SHA-384) instead, set signingAlgorithm to ES384. For the configuration, see JWT-SVID authorization (Preview).

Note

The default quota for GetWebIdentityToken is 200 requests per second. To request a higher quota, request a quota increase for AWS STS. For more information, see IAM and AWS STS quotas in the IAM User Guide.