Skip to content

Commit a9544f7

Browse files
Benbentwoclaude
andcommitted
docs: Update PRD to use native SDK instead of AWS CLI wrapper
Change implementation approach from wrapping `aws login` CLI command to native OAuth2 Authorization Code flow with PKCE using AWS SDK. Removes external AWS CLI dependency requirement. 🤖 Generated with Claude Code Co-Authored-By: Claude Haiku 4.5 <[email protected]>
1 parent d3e7503 commit a9544f7

File tree

1 file changed

+34
-27
lines changed

1 file changed

+34
-27
lines changed

docs/prd/aws-browser-auth.md

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ Two new events are logged:
9797

9898
| ID | Requirement | Priority |
9999
|----|-------------|----------|
100-
| NFR-1 | No new Go dependencies (use AWS CLI wrapper) | P0 |
101-
| NFR-2 | Unit tests with mocked CLI executor | P0 |
100+
| NFR-1 | Native SDK implementation (no AWS CLI dependency) | P0 |
101+
| NFR-2 | Unit tests with mocked HTTP server and OAuth flow | P0 |
102102
| NFR-3 | Documentation in Docusaurus | P0 |
103103
| NFR-4 | Error messages include actionable hints | P1 |
104104

@@ -207,8 +207,7 @@ Authorization code: █
207207

208208
### User Requirements
209209

210-
1. **AWS CLI 2.32.0+** must be installed
211-
2. **IAM Permissions**: Principal must have `SignInLocalDevelopmentAccess` managed policy or equivalent:
210+
1. **IAM Permissions**: Principal must have `SignInLocalDevelopmentAccess` managed policy or equivalent:
212211
```json
213212
{
214213
"Version": "2012-10-17",
@@ -224,7 +223,8 @@ Authorization code: █
224223
]
225224
}
226225
```
227-
3. **Console Access**: IAM user must have console sign-in enabled
226+
2. **Console Access**: IAM user must have console sign-in enabled
227+
3. **Browser Access**: Default browser must be available (or use remote mode for headless)
228228

229229
### Organizational Controls
230230

@@ -233,35 +233,42 @@ Authorization code: █
233233

234234
## Implementation Approach
235235

236-
### Recommended: AWS CLI Wrapper
236+
### Recommended: Native AWS SDK Integration
237237

238-
Wrap the AWS CLI `aws login` command rather than implementing OAuth2 natively:
238+
Implement the OAuth2 Authorization Code flow with PKCE directly using the AWS SDK for Go. The AWS SDK supports this authentication flow natively.
239239

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:
240+
**Technical Implementation:**
241+
1. Start local HTTP server on `http://127.0.0.1:<port>/oauth/callback`
242+
2. Generate PKCE code verifier (random 32-byte string, base64url encoded)
243+
3. Generate code challenge (SHA-256 hash of verifier, base64url encoded)
244+
4. Open browser to authorization URL:
245+
```
246+
https://{region}.signin.aws.amazon.com/authorize?
247+
client_id=arn:aws:signin:::devtools/same-device
248+
&redirect_uri=http://127.0.0.1:{port}/oauth/callback
249+
&response_type=code
250+
&code_challenge={challenge}
251+
&code_challenge_method=S256
252+
&scope=openid
253+
```
254+
5. Receive authorization code via callback
255+
6. Exchange code for tokens via AWS signin service
256+
7. Use tokens to obtain temporary AWS credentials
253257

254258
**Advantages:**
255-
- No external dependency
256-
- Full control over UX
257-
- Could potentially work without AWS CLI
259+
- No external AWS CLI dependency
260+
- Full control over UX and error handling
261+
- Follows existing atmos auth patterns (similar to SSO device flow)
262+
- SDK handles token refresh and credential management
258263

259264
**Disadvantages:**
260-
- Must implement credential refresh mechanism
261-
- Token endpoint details not fully documented
262-
- Higher maintenance burden
265+
- More code to implement and maintain
266+
- Must handle PKCE flow ourselves
263267

264-
**Recommendation:** Start with AWS CLI wrapper approach. Consider native implementation if CLI dependency becomes problematic.
268+
**Note:** The AWS CLI wrapper approach was considered but rejected because:
269+
- Adds external dependency (AWS CLI 2.32.0+)
270+
- Less control over authentication UX
271+
- SDK already supports this flow
265272

266273
## Security Considerations
267274

0 commit comments

Comments
 (0)