Skip to content

Commit 558c2ea

Browse files
authored
Direct IAM Federation, Inference Profiles, and Claude Sonnet 4.5 Support (#36)
* feat: Add Direct IAM federation support alongside Cognito Identity Pool (#32) This major update introduces Direct IAM federation as an alternative to Cognito Identity Pool, providing more flexibility in authentication methods. Both federation types are fully supported and can be selected during initialization. Key changes: - Add Direct IAM federation using STS AssumeRoleWithWebIdentity - Support for Okta, Azure AD, Auth0, and Cognito User Pools via Direct IAM - Rename cognito_auth module to credential_provider (more accurate name) - Add provider-specific CloudFormation templates for better organization - Improve CloudFormation error handling with custom exceptions - Add automatic federation type detection in credential provider - Update all CLI commands to support both federation methods - Session duration configurable up to 12 hours for Direct IAM Infrastructure: - New bedrock-authentication.yaml as unified template - Provider-specific templates for Okta, Azure, Auth0, Cognito User Pools - Remove dual mode option - users choose either Direct IAM or Cognito - Improved IAM role structure with provider-specific roles Documentation: - Update README, ARCHITECTURE, DEPLOYMENT, and CLI_REFERENCE docs - Document both authentication methods without bias - Clear explanations of configuration options Breaking changes: - cognito_auth module renamed to credential_provider - New configuration field: federation_type (direct/cognito) - New configuration field: federated_role_arn (for Direct IAM) Migration: - Existing Cognito deployments continue to work - Auto-detection of federation type based on config - Backward compatibility maintained * feat: Add Bedrock inference profile permissions for cross-region support (#33) (#34) - Added bedrock:ListInferenceProfiles permission to list available inference profiles - Added bedrock:GetInferenceProfile permission to get details about specific profiles - Updated ARCHITECTURE.md to document all IAM permissions granted to authenticated users - These permissions enable cross-region inference profile discovery and selection * feat: Add Bedrock inference profile permissions to Direct IAM templates - Added bedrock:ListInferenceProfiles and bedrock:GetInferenceProfile permissions - Updated all provider-specific templates (Okta, Azure, Auth0, Cognito User Pool) - Updated legacy bedrock-authentication.yaml for consistency - Enables cross-region inference profile discovery and selection for all federation types Related: #35 (tracks removal of deprecated fallback template) * feat: Add Direct IAM federation, inference profiles, and Claude Sonnet 4.5 support
1 parent 578acc5 commit 558c2ea

31 files changed

+4036
-877
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,9 @@ tests/
5353
assets/docs/planning
5454

5555
.pytest_cache/
56-
.ruff_cache/
56+
.ruff_cache/
57+
.coverage
58+
.epcc
59+
60+
EPCC_*
61+
PRs/

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.yaml

CHANGELOG.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [1.1.0] - 2025-09-30
9+
10+
### Added
11+
12+
- **Direct IAM Federation**: Alternative to Cognito Identity Pool for authentication (#32)
13+
- Support for Okta, Azure AD, Auth0, and Cognito User Pools
14+
- Session duration configurable up to 12 hours
15+
- Provider-specific CloudFormation templates
16+
- Automatic federation type detection
17+
- **Claude Sonnet 4.5 Support**: Full support for the latest Claude Sonnet 4.5 model
18+
- US CRIS profile (us-east-1, us-east-2, us-west-1, us-west-2)
19+
- EU CRIS profile (8 European regions: Frankfurt, Zurich, Stockholm, Ireland, London, Paris, Milan, Spain)
20+
- Japan CRIS profile (Tokyo, Osaka)
21+
- Global CRIS profile (23 regions worldwide including North America, Europe, Asia Pacific, and South America)
22+
- **Inference Profile Permissions**: Added bedrock:ListInferenceProfiles and bedrock:GetInferenceProfile (#33, #34)
23+
- **CloudFormation Utilities**: New exception handling and CloudFormation helper utilities
24+
- **Global Endpoint Support**: IAM policies now properly support global inference profile ARNs
25+
26+
### Changed
27+
28+
- **Module Rename**: `cognito_auth``credential_provider` (more accurate naming)
29+
- **IAM Policy Structure**: Split IAM policy statements into separate regional and global statements
30+
- Regional resources use `aws:RequestedRegion` condition
31+
- Global resources have no region condition
32+
- **Deploy Command**: Refactored deploy.py with improved error handling and provider template support
33+
- **Region Configuration**: Init wizard now dynamically uses regions from model profiles instead of hardcoded fallbacks
34+
- **CloudWatch Metrics**: Fixed Resource specification to use '\*' instead of Bedrock ARNs
35+
- **Configuration Schema**: Added federation_type and federated_role_arn fields
36+
37+
### Fixed
38+
39+
- Global endpoint access now works correctly without region condition blocking
40+
- CloudFormation error handling improved across all commands
41+
- Region condition no longer incorrectly applied to regionless global endpoints
42+
- Init process properly handles all CRIS profile regions for selected model
43+
44+
### Infrastructure
45+
46+
- 4 new provider-specific CloudFormation templates (Okta, Azure AD, Auth0, Cognito User Pool)
47+
- Improved IAM role structure with provider-specific roles
48+
- CloudFormation exception handling and utilities
49+
50+
### Documentation
51+
52+
- Updated README, ARCHITECTURE, DEPLOYMENT, and CLI_REFERENCE
53+
- Clear explanations of both authentication methods
54+
- Documented configuration options for all providers
55+
56+
## [1.0.0] - Previous Release
57+
58+
Initial release with enterprise authentication support.

README.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ Step-by-step flow for end-users:
113113

114114
## Architecture Overview
115115

116-
![Architecture Diagram](assets/images/credential-flow-diagram.png)
116+
### Authentication Flow (with Cognito Identity Pool)
117117

118-
### Authentication Flow
118+
![Architecture Diagram](assets/images/credential-flow-diagram.png)
119119

120120
1. **User initiates authentication**: User requests access to Amazon Bedrock through Claude Code
121121
2. **OIDC authentication**: User authenticates with their OIDC provider and receives an ID token
@@ -126,6 +126,17 @@ Step-by-step flow for end-users:
126126
7. **Access Amazon Bedrock**: Application uses the temporary credentials to call Amazon Bedrock
127127
8. **Bedrock response**: Amazon Bedrock processes the request and returns the response
128128

129+
### Authentication Flow (direct to IAM)
130+
131+
![Architecture Diagram](assets/images/credential-flow-direct-diagram.png)
132+
133+
1. **User initiates authentication**: User requests access to Amazon Bedrock through Claude Code
134+
2. **OIDC authentication**: User authenticates with their OIDC provider and receives an ID token
135+
3. **Token submission to IAM**: Application sends the OIDC ID token to Amazon Cognito
136+
4. **IAM returns credentials**: AWS IAM validates and returns temporary AWS credentials
137+
5. **Access Amazon Bedrock**: Application uses the temporary credentials to call Amazon Bedrock
138+
6. **Bedrock response**: Amazon Bedrock processes the request and returns the response
139+
129140
### Cost
130141

131142
_You are responsible for the cost of the AWS services used while running this guidance._
@@ -155,7 +166,7 @@ Based on AWS Pricing Calculator: [View Detailed Estimate](https://calculator.aws
155166

156167
- AWS account with appropriate IAM permissions to create:
157168
- CloudFormation stacks
158-
- Cognito Identity Pools
169+
- IAM OIDC Providers or Cognito Identity Pools
159170
- IAM roles and policies
160171
- (Optional) Amazon Elastic Container Service (Amazon ECS) tasks and Amazon CloudWatch dashboards
161172
- (Optional) Amazon Athena, AWS Glue, AWS Lambda, and Amazon Data Firehose resources
@@ -182,7 +193,7 @@ Based on AWS Pricing Calculator: [View Detailed Estimate](https://calculator.aws
182193

183194
The guidance can be deployed in any AWS region that supports:
184195

185-
- Amazon Cognito Identity Pools
196+
- IAM OIDC Providers or Amazon Cognito Identity Pools
186197
- Amazon Bedrock
187198
- (Optional) Amazon Elastic Container Service (Amazon ECS) tasks and Amazon CloudWatch dashboards
188199
- (Optional) Amazon Athena, AWS Glue, AWS Lambda, and Amazon Data Firehose resources
@@ -257,8 +268,8 @@ This creates the following AWS resources:
257268

258269
**Authentication Infrastructure:**
259270

260-
- Amazon Cognito Identity Pool for OIDC federation
261-
- IAM OIDC Provider trust relationship
271+
- IAM OIDC Provider or Amazon Cognito Identity Pool for OIDC federation
272+
- IAM trust relationship for federated access
262273
- IAM role with policies for:
263274
- Bedrock model invocation in specified regions
264275
- CloudWatch metrics (if monitoring enabled)

assets/docs/ARCHITECTURE.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,27 @@ The Claude Code authentication system enables secure, scalable access to Amazon
1212

1313
### Authentication Components
1414

15-
The core authentication component is the credential process located in `source/cognito_auth/`. This implements a complete OAuth2/OIDC client with PKCE flow for secure authentication without client secrets. When packaged for distribution, PyInstaller compiles this into a standalone executable that end users can run without needing Python installed. The credential process supports multiple identity providers including Okta, Azure AD, Auth0, and Cognito User Pools through a flexible provider registry system. Once authenticated, credentials are cached either in the operating system's secure keyring or in session files, depending on the organization's preference. The implementation follows the AWS CLI credential process protocol, making it transparent to any AWS SDK or tool.
15+
The core authentication component is the credential process located in `source/credential_provider/`. This implements a complete OAuth2/OIDC client with PKCE flow for secure authentication without client secrets. When packaged for distribution, PyInstaller compiles this into a standalone executable that end users can run without needing Python installed. The credential process supports multiple identity providers including Okta, Azure AD, Auth0, and Cognito User Pools through a flexible provider registry system. Once authenticated, credentials are cached either in the operating system's secure keyring or in session files, depending on the organization's preference. The implementation follows the AWS CLI credential process protocol, making it transparent to any AWS SDK or tool.
1616

1717
The management CLI in `source/claude_code_with_bedrock/` provides IT administrators with tools to deploy and manage the infrastructure. Built on the Cleo framework, it offers an intuitive command-line interface for initialization, deployment, and package generation. This component is used only during setup and is not distributed to end users.
1818

1919
### AWS Infrastructure Components
2020

21-
The authentication infrastructure centers on an Amazon Cognito Identity Pool that federates OIDC tokens into AWS credentials. This creates a trust relationship between the organization's identity provider and AWS through an IAM OIDC Provider. The associated IAM role grants permissions specifically for Amazon Bedrock model invocation in configured regions. Every API call includes session tags containing the user's email and subject claim, ensuring complete attribution in CloudTrail logs.
21+
The authentication infrastructure supports two federation methods. With Direct IAM Federation, an IAM OIDC Provider creates the trust relationship between the organization's identity provider and AWS, allowing direct token exchange via STS. With Cognito Identity Pool, Amazon Cognito acts as an intermediary that federates OIDC tokens into AWS credentials. Both methods use IAM roles that grant permissions specifically for Amazon Bedrock model invocation in configured regions. Every API call includes session tags containing the user's email and subject claim, ensuring complete attribution in CloudTrail logs.
22+
23+
#### IAM Permissions
24+
25+
The IAM role assigned to authenticated users grants the following Amazon Bedrock permissions:
26+
27+
- `bedrock:InvokeModel` - Invoke foundation models for text generation
28+
- `bedrock:InvokeModelWithResponseStream` - Invoke models with streaming responses
29+
- `bedrock:ListFoundationModels` - List available foundation models
30+
- `bedrock:GetFoundationModel` - Get details about specific models
31+
- `bedrock:GetFoundationModelAvailability` - Check model availability in regions
32+
- `bedrock:ListInferenceProfiles` - List available cross-region inference profiles
33+
- `bedrock:GetInferenceProfile` - Get details about specific inference profiles
34+
35+
These permissions are scoped to the configured regions and enable users to discover and invoke models through cross-region inference profiles, ensuring optimal performance and availability.
2236

2337
#### IAM Permissions
2438

@@ -42,9 +56,25 @@ For organizations requiring detailed analytics, the optional analytics stack pro
4256

4357
The authentication flow begins when Claude Code requests AWS credentials through the AWS CLI. The CLI invokes our credential process executable, which initiates an OAuth2 flow with PKCE (Proof Key for Code Exchange) to ensure security without requiring client secrets. A browser window opens automatically, directing the user to their organization's identity provider for authentication.
4458

45-
After successful authentication, the identity provider redirects back to the local callback server with an authorization code. The credential process exchanges this code for OIDC tokens, then presents the ID token to Amazon Cognito Identity Pool. Cognito validates the token and calls STS AssumeRoleWithWebIdentity to obtain temporary AWS credentials. These credentials include session tags containing the user's email and subject claim, ensuring every subsequent API call to Amazon Bedrock can be attributed to the specific user.
59+
After successful authentication, the identity provider redirects back to the local callback server with an authorization code. The credential process exchanges this code for OIDC tokens. The system then uses one of two authentication methods to obtain AWS credentials:
60+
61+
### Authentication Methods
62+
63+
The system supports two authentication methods:
64+
65+
**Direct IAM Federation**
66+
- Uses IAM OIDC Provider with STS AssumeRoleWithWebIdentity
67+
- Direct federation from OIDC tokens to AWS credentials
68+
- Configurable session duration up to 12 hours
69+
70+
**Cognito Identity Pool**
71+
- Uses Amazon Cognito Identity Pool as federation broker
72+
- Cognito manages the OIDC to AWS credential exchange
73+
- Configurable session duration up to 8 hours
74+
75+
The authentication method is selected during initial configuration and both methods provide full CloudTrail attribution through session tags. These credentials include session tags containing the user's email and subject claim, ensuring every subsequent API call to Amazon Bedrock can be attributed to the specific user.
4676

47-
The temporary credentials are returned to Claude Code through the standard AWS CLI credential process protocol. By default, credentials last for one hour but can be configured up to eight hours. The entire flow operates without any client secrets or long-lived credentials, following zero-trust security principles. Credentials are cached securely using either the operating system's keyring service or encrypted session files, preventing repeated authentication requests during the session lifetime.
77+
The temporary credentials are returned to Claude Code through the standard AWS CLI credential process protocol. The entire flow operates without any client secrets or long-lived credentials, following zero-trust security principles. Credentials are cached securely using either the operating system's keyring service or encrypted session files, preventing repeated authentication requests during the session lifetime.
4878

4979
## AWS CLI Credential Process Protocol
5080

assets/docs/CLI_REFERENCE.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ poetry run ccwb init [options]
6060

6161
- Checks prerequisites (AWS CLI, credentials, Python version)
6262
- Prompts for OIDC provider configuration
63-
- Configures AWS settings (region, identity pool name)
63+
- Prompts for authentication method selection:
64+
- Direct IAM: Uses IAM OIDC Provider for federation
65+
- Cognito: Uses Cognito Identity Pool for federation
66+
- Configures AWS settings (region, stack names)
6467
- Prompts for Claude model selection (Opus, Sonnet, Haiku)
6568
- Configures cross-region inference profiles (US, Europe, APAC)
6669
- Prompts for source region selection for model inference
@@ -90,14 +93,14 @@ poetry run ccwb deploy [stack] [options]
9093

9194
**What it does:**
9295

93-
- Deploys Cognito Identity Pool for authentication
96+
- Deploys authentication infrastructure (IAM OIDC Provider or Cognito Identity Pool)
9497
- Creates IAM roles and policies for Bedrock access
9598
- Deploys monitoring infrastructure (if enabled)
96-
- Shows stack outputs including Identity Pool ID
99+
- Shows stack outputs including authentication resource identifiers
97100

98101
**Stacks deployed:**
99102

100-
1. **auth** - Cognito Identity Pool and IAM roles (always required)
103+
1. **auth** - Authentication infrastructure and IAM roles (always required)
101104
2. **networking** - VPC and networking resources for monitoring (optional)
102105
3. **monitoring** - OpenTelemetry collector on ECS Fargate (optional)
103106
4. **dashboard** - CloudWatch dashboard for usage metrics (optional)

assets/docs/DEPLOYMENT.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ poetry install
3434

3535
The `ccwb` (Claude Code with Bedrock) CLI tool guides you through deployment with an interactive wizard. Run `poetry run ccwb init` to begin. The wizard walks you through each configuration decision, starting with your OIDC provider details - enter the domain and Client ID you noted earlier.
3636

37+
The wizard asks you to choose an authentication method. You can select either Direct IAM federation or Cognito Identity Pool based on your organization's requirements. Both methods provide secure OIDC federation to AWS credentials.
38+
3739
Next, you'll select your Claude model and configure regional access. Choose from available Claude models (Opus, Sonnet, Haiku) and select a cross-region inference profile (US, Europe, or APAC) for optimal performance. The wizard will then prompt you to select a source region within your chosen profile for model inference. Finally, choose where to deploy the authentication infrastructure (typically your primary AWS region) and configure optional monitoring setup, which provides usage analytics and cost tracking through OpenTelemetry.
3840

3941
Once configuration is complete, deploy the infrastructure with:
@@ -42,7 +44,7 @@ Once configuration is complete, deploy the infrastructure with:
4244
poetry run ccwb deploy
4345
```
4446

45-
This single command orchestrates the creation of multiple AWS resources. A Cognito Identity Pool establishes the trust relationship with your identity provider. IAM roles and policies grant precisely scoped Bedrock access. If you enabled monitoring, it also deploys an ECS Fargate cluster running OpenTelemetry collector, complete with CloudWatch dashboards.
47+
This single command orchestrates the creation of multiple AWS resources. Depending on your chosen authentication method, it creates either an IAM OIDC Provider or a Cognito Identity Pool to establish the trust relationship with your identity provider. IAM roles and policies grant precisely scoped Bedrock access. If you enabled monitoring, it also deploys an ECS Fargate cluster running OpenTelemetry collector, complete with CloudWatch dashboards.
4648

4749
> **Deployment Options**: For more control, see the [CLI Reference](CLI_REFERENCE.md) for deploying specific stacks or using dry-run mode.
4850

assets/docs/WINDOWS_BUILD_SYSTEM.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ C:\Python312\python.exe -m nuitka \
513513
--output-filename=credential-process-windows.exe \
514514
--output-dir=. \
515515
--remove-output \ # Clean up build artifacts
516-
source/cognito_auth/__main__.py
516+
source/credential_provider/__main__.py
517517
```
518518

519519
### Build Performance
@@ -600,7 +600,7 @@ C:\Python312\python.exe -m nuitka \
600600

601601
```
602602
/source/
603-
├── cognito_auth/
603+
├── credential_provider/
604604
│ └── __main__.py # Main authentication module
605605
├── otel_helper/
606606
│ └── __main__.py # Telemetry helper module
160 KB
Loading

0 commit comments

Comments
 (0)