Skip to content

Commit d3e7503

Browse files
Benbentwoclaude
andcommitted
docs: Add PRD for AWS browser-based authentication (aws/login provider)
Add product requirements document for implementing browser-based OAuth2 authentication for root and IAM identities using the AWS CLI login command. Covers user stories, technical details, requirements, configuration schema, and implementation approach. 🤖 Generated with Claude Code Co-Authored-By: Claude Haiku 4.5 <[email protected]>
1 parent 3840735 commit d3e7503

File tree

1 file changed

+330
-0
lines changed

1 file changed

+330
-0
lines changed

docs/prd/aws-browser-auth.md

Lines changed: 330 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,330 @@
1+
# PRD: AWS Browser-Based Authentication for Root and IAM Identities
2+
3+
**Status:** Draft
4+
**Author:** Cloud Posse
5+
**Created:** 2025-12-17
6+
**Linear Issue:** [DEV-3829](https://linear.app/cloudposse/issue/DEV-3829)
7+
8+
## Overview
9+
10+
Add support for AWS browser-based authentication using the new `aws login` command introduced in AWS CLI 2.32.0. This enables developers to authenticate to AWS using the same credentials they use for the AWS Management Console, eliminating the need for long-term IAM access keys.
11+
12+
## Problem Statement
13+
14+
Currently, atmos supports AWS authentication via:
15+
- **IAM Identity Center (SSO)** - `aws/iam-identity-center` provider
16+
- **SAML** - `aws/saml` provider
17+
- **Static IAM User Credentials** - `aws/user` identity
18+
19+
However, many AWS users authenticate to the console using:
20+
- Root user credentials
21+
- IAM user username/password
22+
- Federated identity providers (non-SSO)
23+
24+
These users currently have no secure way to obtain programmatic credentials in atmos without creating long-term access keys, which AWS discourages as a security risk.
25+
26+
## Solution
27+
28+
Introduce a new `aws/login` provider that leverages the AWS CLI's `aws login` command to obtain temporary credentials through browser-based OAuth2 authentication with PKCE.
29+
30+
## User Stories
31+
32+
### US-1: IAM User Authentication
33+
**As** a developer with an IAM user account
34+
**I want** to authenticate using my console username and password
35+
**So that** I can use atmos without creating long-term access keys
36+
37+
### US-2: Root User Authentication
38+
**As** an AWS account administrator
39+
**I want** to authenticate using root credentials when necessary
40+
**So that** I can perform privileged operations securely
41+
42+
### US-3: Federated User Authentication
43+
**As** a developer who signs in via corporate identity provider
44+
**I want** to use my existing console session for CLI access
45+
**So that** I have a seamless authentication experience
46+
47+
### US-4: Headless Environment Authentication
48+
**As** a developer working on a remote server without a browser
49+
**I want** to authenticate using a manual authorization code flow
50+
**So that** I can work in headless environments
51+
52+
### US-5: Role Chaining
53+
**As** a developer
54+
**I want** to assume IAM roles using my login credentials
55+
**So that** I can access resources in different accounts
56+
57+
## Technical Details
58+
59+
### AWS Login OAuth2 Flow
60+
61+
The `aws login` command uses OAuth 2.0 Authorization Code flow with PKCE:
62+
63+
1. **Client Registration**: Uses fixed client ID `arn:aws:signin:::devtools/same-device`
64+
2. **Authorization Endpoint**: `https://{region}.signin.aws.amazon.com/authorize`
65+
3. **PKCE**: SHA-256 code challenge method
66+
4. **Callback**: Local server at `http://127.0.0.1:<port>/oauth/callback`
67+
5. **IAM Actions**: `signin:AuthorizeOAuth2Access`, `signin:CreateOAuth2Token`
68+
69+
### Credential Lifecycle
70+
71+
- **Auto-refresh**: Credentials are automatically rotated every 15 minutes
72+
- **Session duration**: Valid up to 12 hours (limited by IAM principal's max session)
73+
- **Cache location**: `~/.aws/login/cache` (or `AWS_LOGIN_CACHE_DIRECTORY`)
74+
75+
### CloudTrail Events
76+
77+
Two new events are logged:
78+
- `AuthorizeOAuth2Access` - When authorization is granted
79+
- `CreateOAuth2Token` - When tokens are exchanged
80+
81+
## Requirements
82+
83+
### Functional Requirements
84+
85+
| ID | Requirement | Priority |
86+
|----|-------------|----------|
87+
| FR-1 | Support browser-based OAuth2 authentication flow | P0 |
88+
| FR-2 | Support headless/remote mode with manual code entry | P0 |
89+
| FR-3 | Cache credentials following AWS CLI conventions | P0 |
90+
| FR-4 | Validate AWS CLI version >= 2.32.0 | P0 |
91+
| FR-5 | Integrate with existing `aws/assume-role` identity for role chaining | P0 |
92+
| FR-6 | Support multiple profiles/providers | P1 |
93+
| FR-7 | Display authentication status with spinner UI | P1 |
94+
| FR-8 | Auto-detect non-TTY and switch to remote mode | P2 |
95+
96+
### Non-Functional Requirements
97+
98+
| ID | Requirement | Priority |
99+
|----|-------------|----------|
100+
| NFR-1 | No new Go dependencies (use AWS CLI wrapper) | P0 |
101+
| NFR-2 | Unit tests with mocked CLI executor | P0 |
102+
| NFR-3 | Documentation in Docusaurus | P0 |
103+
| NFR-4 | Error messages include actionable hints | P1 |
104+
105+
## Configuration Schema
106+
107+
### Provider Configuration
108+
109+
```yaml
110+
auth:
111+
providers:
112+
<provider-name>:
113+
kind: aws/login
114+
region: <aws-region> # Required: AWS region
115+
session:
116+
duration: <duration> # Optional: Session duration (default: 12h, max: 12h)
117+
spec:
118+
remote: <bool> # Optional: Force headless mode (default: false)
119+
profile: <string> # Optional: AWS CLI profile name (default: atmos-<provider-name>)
120+
```
121+
122+
### Example Configurations
123+
124+
#### Basic Usage
125+
```yaml
126+
auth:
127+
providers:
128+
aws-console:
129+
kind: aws/login
130+
region: us-east-1
131+
```
132+
133+
#### With Role Assumption
134+
```yaml
135+
auth:
136+
providers:
137+
aws-console:
138+
kind: aws/login
139+
region: us-east-1
140+
141+
identities:
142+
prod-admin:
143+
kind: aws/assume-role
144+
via:
145+
provider: aws-console
146+
principal:
147+
role_arn: arn:aws:iam::123456789012:role/AdminRole
148+
```
149+
150+
#### Headless Mode
151+
```yaml
152+
auth:
153+
providers:
154+
aws-console-remote:
155+
kind: aws/login
156+
region: us-east-1
157+
spec:
158+
remote: true
159+
```
160+
161+
## User Experience
162+
163+
### Interactive Flow (Browser Available)
164+
165+
```
166+
$ atmos auth login --provider aws-console
167+
168+
╭──────────────────────────────────────────────────────────╮
169+
│ 🔐 AWS Browser Authentication │
170+
│ │
171+
│ Opening browser for authentication... │
172+
│ If the browser doesn't open, visit:
173+
│ https://us-east-1.signin.aws.amazon.com/authorize?... │
174+
╰──────────────────────────────────────────────────────────╯
175+
176+
⠋ Waiting for authentication...
177+
178+
✓ Authentication successful!
179+
180+
Provider aws-console
181+
Account 123456789012
182+
Principal arn:aws:iam::123456789012:user/developer
183+
Region us-east-1
184+
Expires 2025-12-17 22:00:00 UTC (11h 59m)
185+
```
186+
187+
### Headless Flow (Remote Mode)
188+
189+
```
190+
$ atmos auth login --provider aws-console-remote
191+
192+
╭──────────────────────────────────────────────────────────╮
193+
│ 🔐 AWS Browser Authentication (Remote Mode) │
194+
│ │
195+
│ Visit this URL on a device with a browser: │
196+
│ https://us-east-1.signin.aws.amazon.com/authorize?... │
197+
│ │
198+
│ After signing in, paste the authorization code below. │
199+
╰──────────────────────────────────────────────────────────╯
200+
201+
Authorization code: █
202+
203+
✓ Authentication successful!
204+
```
205+
206+
## Prerequisites
207+
208+
### User Requirements
209+
210+
1. **AWS CLI 2.32.0+** must be installed
211+
2. **IAM Permissions**: Principal must have `SignInLocalDevelopmentAccess` managed policy or equivalent:
212+
```json
213+
{
214+
"Version": "2012-10-17",
215+
"Statement": [
216+
{
217+
"Effect": "Allow",
218+
"Action": [
219+
"signin:AuthorizeOAuth2Access",
220+
"signin:CreateOAuth2Token"
221+
],
222+
"Resource": "*"
223+
}
224+
]
225+
}
226+
```
227+
3. **Console Access**: IAM user must have console sign-in enabled
228+
229+
### Organizational Controls
230+
231+
- Organizations can deny these actions via SCPs to prevent usage
232+
- Centralized root access management can prevent root login on member accounts
233+
234+
## Implementation Approach
235+
236+
### Recommended: AWS CLI Wrapper
237+
238+
Wrap the AWS CLI `aws login` command rather than implementing OAuth2 natively:
239+
240+
**Advantages:**
241+
- AWS CLI handles credential refresh (15-minute rotation)
242+
- Maintains compatibility as AWS evolves the protocol
243+
- Credential caching follows AWS conventions
244+
- Simpler implementation and maintenance
245+
246+
**Disadvantages:**
247+
- Requires AWS CLI 2.32.0+ as external dependency
248+
- Less control over the authentication UX
249+
250+
### Alternative: Native OAuth2 Implementation
251+
252+
Implement the OAuth2 + PKCE flow directly in Go:
253+
254+
**Advantages:**
255+
- No external dependency
256+
- Full control over UX
257+
- Could potentially work without AWS CLI
258+
259+
**Disadvantages:**
260+
- Must implement credential refresh mechanism
261+
- Token endpoint details not fully documented
262+
- Higher maintenance burden
263+
264+
**Recommendation:** Start with AWS CLI wrapper approach. Consider native implementation if CLI dependency becomes problematic.
265+
266+
## Security Considerations
267+
268+
1. **No Long-Term Credentials**: Only temporary credentials are issued
269+
2. **PKCE Protection**: Authorization code interception attacks are mitigated
270+
3. **Short-Lived Tokens**: Credentials rotate every 15 minutes
271+
4. **CloudTrail Logging**: All authentication events are logged
272+
5. **MFA Support**: MFA requirements are enforced by AWS during browser sign-in
273+
274+
## Testing Strategy
275+
276+
### Unit Tests
277+
- Provider configuration validation
278+
- AWS CLI version detection and validation
279+
- Cache file parsing (valid, expired, malformed)
280+
- Error handling for CLI failures
281+
282+
### Integration Tests
283+
- Manual testing with real AWS account
284+
- Headless mode flow verification
285+
286+
### Snapshot Tests
287+
- UI output consistency across platforms
288+
289+
## Documentation
290+
291+
### Files to Create/Update
292+
- `website/docs/cli/commands/auth/login.mdx` - Update with new provider
293+
- `website/docs/core-concepts/authentication/aws-login.mdx` - New concept page
294+
- Schema documentation updates
295+
296+
## Rollout Plan
297+
298+
### Phase 1: Core Implementation
299+
- Create `aws/login` provider
300+
- Implement CLI wrapper with version validation
301+
- Add error handling and hints
302+
303+
### Phase 2: UI and Integration
304+
- Implement browser opening and spinner UI
305+
- Add headless mode support
306+
- Integration with `aws/assume-role`
307+
308+
### Phase 3: Documentation and Polish
309+
- Docusaurus documentation
310+
- Example configurations
311+
- Blog post for release
312+
313+
## Success Metrics
314+
315+
1. **Adoption**: Number of users configuring `aws/login` provider
316+
2. **Error Rate**: Authentication failures due to implementation issues
317+
3. **User Feedback**: GitHub issues and community feedback
318+
319+
## Open Questions
320+
321+
1. **Profile Naming**: Should atmos auto-generate profile names or let users specify?
322+
2. **Auto-Detection**: Should we auto-detect non-TTY and switch to remote mode?
323+
3. **Credential Source**: When using role chaining, should we write credentials to files or pass via environment?
324+
325+
## References
326+
327+
- [AWS Blog: Simplified developer access to AWS with 'aws login'](https://aws.amazon.com/blogs/security/simplified-developer-access-to-aws-with-aws-login/)
328+
- [AWS CLI Login Documentation](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sign-in.html)
329+
- [AWS CLI IAM Identity Center Configuration](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-sso.html)
330+
- [Beyond IAM access keys: Modern authentication approaches](https://aws.amazon.com/blogs/security/beyond-iam-access-keys-modern-authentication-approaches/)

0 commit comments

Comments
 (0)