Skip to content

Commit 1fac45e

Browse files
committed
Add M2M auth documentation and address reviewer feedback
- Add comprehensive M2M authentication workflow documentation (RUNTIME_GATEWAY_AUTH.md) - Remove unnecessary provider name fallback from decorator (CDK always sets env var) - Update CHANGELOG with complete migration details - Enhanced docstring in auth.py for Docker testing fallback - Updated both agent patterns with conditional authentication logic - Added environment variable support in test-agent-docker.py
1 parent 6b69ade commit 1fac45e

File tree

6 files changed

+591
-59
lines changed

6 files changed

+591
-59
lines changed

CHANGELOG.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
- OAuth2 Credential Provider Lambda handler (`infra-cdk/lambdas/oauth2-provider/index.py`) for lifecycle management with Create, Update, and Delete support
13-
- Token refresh helpers (`_fetch_gateway_token`) in both Strands and LangGraph agents to prevent stale token errors
13+
- Conditional token refresh helpers (`_fetch_gateway_token`) in both Strands and LangGraph agents with Runtime (decorator) and Docker (manual) implementations
14+
- Environment variable `USE_AGENTCORE_IDENTITY_OAUTH` for controlling authentication path (Runtime vs Docker)
15+
- Docker testing support with environment variable configuration in `test-scripts/test-agent-docker.py`
1416
- Machine client secret storage in Secrets Manager for OAuth2 authentication
1517
- Runtime environment variable `GATEWAY_CREDENTIAL_PROVIDER_NAME` for OAuth2 provider lookup
1618
- OAuth2 Credential Provider and Token Vault IAM permissions to agent runtime role
1719
- Scoped Secrets Manager IAM permissions to agent runtime role for OAuth2 secrets
20+
- `docs/RUNTIME_GATEWAY_AUTH.md` - Comprehensive documentation of the M2M authentication workflow between AgentCore Runtime and Gateway, covering both deployment (OAuth2 provider registration) and runtime (token retrieval and validation) phases
1821

1922
### Changed
2023

21-
- Migrated Gateway authentication from manual OAuth2 implementation (~70 lines in `patterns/utils/auth.py`) to AgentCore SDK `@requires_access_token` decorator (single-line calls)
24+
- Migrated Gateway authentication to AgentCore SDK `@requires_access_token` decorator for AgentCore Runtime while maintaining manual OAuth2 implementation as fallback for Docker local testing
25+
- Implemented conditional authentication logic in agent patterns to support both Runtime (decorator) and Docker (manual) environments
2226
- Use `cr.Provider` pattern for OAuth2 provider to avoid IAM propagation delays
2327
- Implemented scoped IAM permissions for OAuth2 provider, Token Vault, and Secrets Manager
2428
- Updated OAuth2 Custom Resource to pass secret ARN instead of plaintext value for enhanced security
@@ -27,10 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2731

2832
### Removed
2933

30-
- Manual OAuth2 token fetching function `get_gateway_access_token()` (~70 lines) from `patterns/utils/auth.py`
31-
- Direct Secrets Manager access from agent code
32-
- Manual token caching and refresh logic
33-
- Dependencies on `requests` and `base64` libraries for OAuth2 operations
34+
- Wildcard Secrets Manager IAM permissions from base `AgentCoreRole` utility class (moved to scoped permissions in backend-stack.ts)
3435

3536
### Fixed
3637

@@ -39,9 +40,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3940

4041
### Security
4142

42-
- Enhanced security by delegating OAuth2 token management to AgentCore Identity service
43+
- Enhanced security by delegating OAuth2 token management to AgentCore Identity service in AgentCore Runtime
4344
- Eliminated plaintext secret passing to Custom Resources (now uses ARN references)
44-
- Restricted secret access to AgentCore service principal only via resource policies
4545
- Improved token lifecycle management with automatic refresh and error handling
4646

4747
## [0.3.1] - 2026-02-11

0 commit comments

Comments
 (0)