Skip to content

feat(identity): Add X-Amz-Bedrock-AgentCore-Identity-WAT header propa… - #607

Open
Sudip2403 wants to merge 1 commit into
aws:mainfrom
Sudip2403:feat/identity-wat-propagation
Open

feat(identity): Add X-Amz-Bedrock-AgentCore-Identity-WAT header propa…#607
Sudip2403 wants to merge 1 commit into
aws:mainfrom
Sudip2403:feat/identity-wat-propagation

Conversation

@Sudip2403

Copy link
Copy Markdown

…gation

Add support for workload identity chain propagation across service hops:

  • Add IDENTITY_WAT_HEADER constant and allowlist it in is_forwardable_header
  • Add identity_wat context variable to BedrockAgentCoreContext
  • Extract the WAT header from inbound requests in _build_request_context
  • Auto-propagate on outbound Runtime/Gateway boto3 calls via event handler
  • Add @requires_wat decorator for explicit WAT minting and propagation
  • Register WAT propagation on Runtime data plane client only (Identity is excluded as it is the WAT issuer)
  • Document manual Gateway MCP call propagation pattern
  • Add comprehensive tests for all new functionality

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@Sudip2403
Sudip2403 requested a review from a team July 29, 2026 14:19
@github-actions github-actions Bot added the size/m PR size: M label Jul 29, 2026
…gation

Add support for workload identity chain propagation across service hops:

- Add IDENTITY_WAT_HEADER constant and allowlist it in is_forwardable_header
- Add identity_wat context variable to BedrockAgentCoreContext
- Extract the WAT header from inbound requests in _build_request_context
- Auto-propagate on outbound Runtime/Gateway boto3 calls via event handler
- Add @requires_wat decorator that reads WAT from context (provisioned by
  Runtime platform, no Identity/ACPS calls from customer code)
- Register WAT propagation on Runtime data plane client only
  (Identity is excluded as it is the WAT issuer)
- Document manual Gateway MCP call propagation pattern
- Add comprehensive tests for all new functionality
@Sudip2403
Sudip2403 force-pushed the feat/identity-wat-propagation branch from d9530c0 to 69d2b34 Compare July 29, 2026 23:43
@github-actions github-actions Bot added size/m PR size: M and removed size/m PR size: M labels Jul 29, 2026

@jariy17 jariy17 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. We already store the workload access token in the context. Can we use that instead?

Args:
client: A boto3 client instance (e.g., bedrock-agentcore data plane client).
"""
client.meta.events.register(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of filtering on Line 52, we should call this register for every WAT allowlisted operation (InvokeAgentRuntime).

for op in ("InvokeAgentRuntime", ...):
      self.dp_client.meta.events.register(
          f"before-sign.bedrock-agentcore.{op}",
          _add_identity_wat_header,
          unique_id=f"identity-wat-{op}",
      )

request.headers[IDENTITY_WAT_HEADER] = identity_wat


def register_identity_wat_propagation(client: Any) -> None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please scope this client's type to botocore.client.BaseClient.

"""Unified context manager for Bedrock AgentCore."""

_workload_access_token: ContextVar[Optional[str]] = ContextVar("workload_access_token")
_identity_wat: ContextVar[Optional[str]] = ContextVar("identity_wat", default=None)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are already store WAT in _workload_access_token. Can this PR just use this variable instead of creating a whole new one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/m PR size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants