feat: add simple OAuth for testing MCP flows#390
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a simple OAuth implementation for testing MCP flows by adding new Lambda handlers, extending the core with OAuth domain models and repository support, and wiring the endpoints into the CDK-managed API.
- Added OAuth-related Lambdas under
lambdas/oauth_*for token issuance, revocation, introspection, client registration, management, and authorization flows - Extended
coremodule with OAuth client, token, and authorization code models, commands/queries, and DynamoDB adapter methods - Updated the CDK API (
api.ts) to register new/oauthroutes and seeded a default OAuth client in the user-creation Lambda
Reviewed Changes
Copilot reviewed 30 out of 32 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/user-management-service/src/user-management/lambdas/oauth_authorize_callback/src/main.rs | Fix error handling in handle_callback_get |
| src/user-management-service/lib/user-management-api/api.ts | Correct typo in DynamoDB table name |
| src/user-management-service/src/user-management/lambdas/oauth_token/src/main.rs | Clarify expect message for missing JWT secret |
Comments suppressed due to low confidence (1)
src/user-management-service/lib/user-management-api/api.ts:42
- There's a typo in the table name (
Userss). It should beUsersto match the naming convention used elsewhere.
tableName: `${props.serviceProps.sharedProps.serviceName}-Userss-${props.serviceProps.sharedProps.environment}`,
| let code = code.ok_or_else(|| { | ||
| tracing::error!("No authorization code received"); | ||
| "Missing authorization code".to_string() | ||
| })?; |
There was a problem hiding this comment.
Returning Err(String) here will not match the function's Error type. Instead of using ? on a String, explicitly return an HTTP 400 response (e.g., return empty_response(&StatusCode::BAD_REQUEST)), or map the string into a compatible error.
| let code = code.ok_or_else(|| { | |
| tracing::error!("No authorization code received"); | |
| "Missing authorization code".to_string() | |
| })?; | |
| let code = match code { | |
| Some(code) => code, | |
| None => { | |
| tracing::error!("No authorization code received"); | |
| return empty_response(&StatusCode::BAD_REQUEST); | |
| } | |
| }; |
| async fn load_jwt_secret(config: &SdkConfig) -> Result<String, ()> { | ||
| let ssm_client = aws_sdk_ssm::Client::new(&config); | ||
| let secret_key_name = | ||
| std::env::var("JWT_SECRET_PARAM_NAME").expect("JWT_SECRET_PARAM_NAME name set"); |
There was a problem hiding this comment.
The expect message is unclear. Consider changing it to expect("JWT_SECRET_PARAM_NAME is not set") for consistency with other environment‐variable checks.
| std::env::var("JWT_SECRET_PARAM_NAME").expect("JWT_SECRET_PARAM_NAME name set"); | |
| std::env::var("JWT_SECRET_PARAM_NAME").expect("JWT_SECRET_PARAM_NAME is not set"); |
|
Claude finished @jeastham1993's task —— View job PR Review: OAuth Implementation for MCP FlowsI've completed a comprehensive review of this OAuth implementation. Here's my detailed analysis: Review Tasks:
Code Quality & Best Practices✅ Strengths:
Security Concerns🔴 Critical Issues:
🟡 Security Recommendations:
Bugs & Issues🔴 Confirmed Issues from Copilot:
🟡 Additional Issues Found:
Performance Considerations✅ Good Practices:
Test Coverage🔴 Major Gap:
📋 Recommended Test Coverage:
RecommendationsHigh Priority:
Medium Priority:
Low Priority:
Overall AssessmentThis is a solid OAuth 2.0 implementation with good architectural patterns and comprehensive endpoint coverage. The main concerns are around security hardening, test coverage, and fixing the identified bugs. The implementation follows OAuth 2.0 standards well and includes modern security features like PKCE. Recommendation: ✅ Approve with requested changes - Fix the critical bugs and add test coverage before merging. |
|
Claude finished @jeastham1993's task —— View job PR Review: OAuth Implementation for MCP FlowsI've completed a comprehensive review of this OAuth implementation. Here's my detailed analysis: Review Tasks:
Code Quality & Best Practices✅ Strengths:
Security Concerns🔴 Critical Issues:
🟡 Security Recommendations:
Bugs & Issues🔴 Confirmed Issues from Copilot:
🟡 Additional Issues Found:
Performance Considerations✅ Good Practices:
Test Coverage🔴 Major Gap:
📋 Recommended Test Coverage:
RecommendationsHigh Priority:
Medium Priority:
Low Priority:
Overall AssessmentThis is a solid OAuth 2.0 implementation with good architectural patterns and comprehensive endpoint coverage. The main concerns are around security hardening, test coverage, and fixing the identified bugs. The implementation follows OAuth 2.0 standards well and includes modern security features like PKCE. Recommendation: ✅ Approve with requested changes - Fix the critical bugs and add test coverage before merging. |
| userContext: UserContext, | ||
| requiredScope: Scope | ||
| ): Promise<Response | null> { | ||
| console.log( |
There was a problem hiding this comment.
| async authenticate( | ||
| request: express.Request | ||
| ): Promise<{ userContext: UserContext | null; response?: Response }> { | ||
| console.log(`Authenticating request: ${request.method} ${request.url}`); |
There was a problem hiding this comment.
| // Try introspection as fallback | ||
| const introspectedContext = await this.jwtService.introspectToken(token); | ||
| if (!introspectedContext) { | ||
| console.log(`Introspection failed for token: ${token}`); |
There was a problem hiding this comment.
| ? claims.scope.split(" ").filter((s: string) => s.length > 0) | ||
| : []; | ||
|
|
||
| console.log( |
There was a problem hiding this comment.
|
|
||
| console.log( | ||
| `JWT validation successful. User: ${ | ||
| claims.username |
| ); | ||
| } | ||
|
|
||
| console.log(`Scope check passed for: ${requiredScope}`); |
There was a problem hiding this comment.
| // Extract Bearer token | ||
| const token = this.jwtService.extractBearerToken(authHeader); | ||
|
|
||
| console.log(`Extracted token: ${token}`); |
There was a problem hiding this comment.
| isAuthenticated: true, | ||
| }; | ||
| } catch (error) { | ||
| console.error("JWT validation failed:", error); |
There was a problem hiding this comment.
| return null; | ||
| } | ||
|
|
||
| const introspectionResponse = (await response.json()) as any; |
| algorithms: ["HS256"], | ||
| }); | ||
|
|
||
| console.log(`JWT payload: ${JSON.stringify(payload)}`); |
There was a problem hiding this comment.
|
Claude finished @jeastham1993's task —— View job PR Review: OAuth Implementation for MCP FlowsI've completed a comprehensive review of this OAuth implementation. Here's my detailed analysis: Review Tasks:
Code Quality & Best Practices✅ Strengths:
Security Concerns🔴 Critical Issues:
🟡 Security Recommendations:
Bugs & Issues🔴 Confirmed Issues from Copilot:
🟡 Additional Issues Found:
Performance Considerations✅ Good Practices:
Test Coverage🔴 Major Gap:
📋 Recommended Test Coverage:
RecommendationsHigh Priority:
Medium Priority:
Low Priority:
Overall AssessmentThis is a solid OAuth 2.0 implementation with good architectural patterns and comprehensive endpoint coverage. The main concerns are around security hardening, test coverage, and fixing the identified bugs. The implementation follows OAuth 2.0 standards well and includes modern security features like PKCE. Recommendation: ✅ Approve with requested changes - Fix the critical bugs and add test coverage before merging. |
| ); | ||
|
|
||
| if (!userContext) { | ||
| console.log( |
There was a problem hiding this comment.
|
Claude finished @jeastham1993's task —— View job PR Review: OAuth Implementation for MCP FlowsI've completed a comprehensive review of this OAuth implementation. Here's my detailed analysis: Review Tasks:
Code Quality & Best Practices✅ Strengths:
Security Concerns🔴 Critical Issues:
🟡 Security Recommendations:
Bugs & Issues🔴 Confirmed Issues from Copilot:
🟡 Additional Issues Found:
Performance Considerations✅ Good Practices:
Test Coverage🔴 Major Gap:
📋 Recommended Test Coverage:
RecommendationsHigh Priority:
Medium Priority:
Low Priority:
Overall AssessmentThis is a solid OAuth 2.0 implementation with good architectural patterns and comprehensive endpoint coverage. The main concerns are around security hardening, test coverage, and fixing the identified bugs. The implementation follows OAuth 2.0 standards well and includes modern security features like PKCE. Recommendation: ✅ Approve with requested changes - Fix the critical bugs and add test coverage before merging. |
|
Claude finished @jeastham1993's task —— View job PR Review: OAuth Implementation for MCP FlowsI've completed a comprehensive review of this OAuth implementation. Here's my detailed analysis: Review Tasks:
Code Quality & Best Practices✅ Strengths:
Security Concerns🔴 Critical Issues:
🟡 Security Recommendations:
Bugs & Issues🔴 Confirmed Issues from Copilot:
🟡 Additional Issues Found:
Performance Considerations✅ Good Practices:
Test Coverage🔴 Major Gap:
📋 Recommended Test Coverage:
RecommendationsHigh Priority:
Medium Priority:
Low Priority:
Overall AssessmentThis is a solid OAuth 2.0 implementation with good architectural patterns and comprehensive endpoint coverage. The main concerns are around security hardening, test coverage, and fixing the identified bugs. The implementation follows OAuth 2.0 standards well and includes modern security features like PKCE. Recommendation: ✅ Approve with requested changes - Fix the critical bugs and add test coverage before merging. |
|
Claude finished @jeastham1993's task —— View job PR Review: OAuth Implementation for MCP FlowsI've completed a comprehensive review of this OAuth implementation. Here's my detailed analysis: Review Tasks:
Code Quality & Best Practices✅ Strengths:
Security Concerns🔴 Critical Issues:
🟡 Security Recommendations:
Bugs & Issues🔴 Confirmed Issues from Copilot:
🟡 Additional Issues Found:
Performance Considerations✅ Good Practices:
Test Coverage🔴 Major Gap:
📋 Recommended Test Coverage:
RecommendationsHigh Priority:
Medium Priority:
Low Priority:
Overall AssessmentThis is a solid OAuth 2.0 implementation with good architectural patterns and comprehensive endpoint coverage. The main concerns are around security hardening, test coverage, and fixing the identified bugs. The implementation follows OAuth 2.0 standards well and includes modern security features like PKCE. Recommendation: ✅ Approve with requested changes - Fix the critical bugs and add test coverage before merging. |
| // Validate token | ||
| const userContext = await this.jwtService.validateAccessToken(token); | ||
|
|
||
| console.log( |
There was a problem hiding this comment.
|
Claude finished @jeastham1993's task —— View job PR Review: OAuth Implementation for MCP FlowsI've completed a comprehensive review of this OAuth implementation. Here's my detailed analysis: Review Tasks:
Code Quality & Best Practices✅ Strengths:
Security Concerns🔴 Critical Issues:
🟡 Security Recommendations:
Bugs & Issues🔴 Confirmed Issues from Copilot:
🟡 Additional Issues Found:
Performance Considerations✅ Good Practices:
Test Coverage🔴 Major Gap:
📋 Recommended Test Coverage:
RecommendationsHigh Priority:
Medium Priority:
Low Priority:
Overall AssessmentThis is a solid OAuth 2.0 implementation with good architectural patterns and comprehensive endpoint coverage. The main concerns are around security hardening, test coverage, and fixing the identified bugs. The implementation follows OAuth 2.0 standards well and includes modern security features like PKCE. Recommendation: ✅ Approve with requested changes - Fix the critical bugs and add test coverage before merging. |
|
Claude finished @jeastham1993's task —— View job PR Review: OAuth Implementation for MCP FlowsI've completed a comprehensive review of this OAuth implementation. Here's my detailed analysis: Review Tasks:
Code Quality & Best Practices✅ Strengths:
Security Concerns🔴 Critical Issues:
🟡 Security Recommendations:
Bugs & Issues🔴 Confirmed Issues from Copilot:
🟡 Additional Issues Found:
Performance Considerations✅ Good Practices:
Test Coverage🔴 Major Gap:
📋 Recommended Test Coverage:
RecommendationsHigh Priority:
Medium Priority:
Low Priority:
Overall AssessmentThis is a solid OAuth 2.0 implementation with good architectural patterns and comprehensive endpoint coverage. The main concerns are around security hardening, test coverage, and fixing the identified bugs. The implementation follows OAuth 2.0 standards well and includes modern security features like PKCE. Recommendation: ✅ Approve with requested changes - Fix the critical bugs and add test coverage before merging. |
|
Claude finished @jeastham1993's task —— View job I'm conducting a comprehensive review of this OAuth implementation for MCP flows. Review Tasks:
Code Quality & Best Practices✅ Strengths:
Security Concerns🔴 Critical Issues:
🟡 Security Recommendations:
Bugs & Issues🔴 Confirmed Issues from Copilot:
🟡 Additional Issues Found:
Performance Considerations✅ Good Practices:
Test Coverage🔴 Major Gap:
📋 Recommended Test Coverage:
RecommendationsHigh Priority:
Medium Priority:
Low Priority:
Overall AssessmentThis is a solid OAuth 2.0 implementation with good architectural patterns and comprehensive endpoint coverage. The main concerns are around security hardening, test coverage, and fixing the identified bugs. The implementation follows OAuth 2.0 standards well and includes modern security features like PKCE. Recommendation: ✅ Approve with requested changes - Fix the critical bugs and add test coverage before merging. |
|
Claude finished @jeastham1993's task —— View job PR Review: OAuth Implementation for MCP FlowsI've completed a comprehensive review of this OAuth implementation. Here's my detailed analysis: Review Tasks:
Code Quality & Best Practices✅ Strengths:
Security Concerns🔴 Critical Issues:
🟡 Security Recommendations:
Bugs & Issues🔴 Confirmed Issues from Copilot:
🟡 Additional Issues Found:
Performance Considerations✅ Good Practices:
Test Coverage🔴 Major Gap:
📋 Recommended Test Coverage:
RecommendationsHigh Priority:
Medium Priority:
Low Priority:
Overall AssessmentThis is a solid OAuth 2.0 implementation with good architectural patterns and comprehensive endpoint coverage. The main concerns are around security hardening, test coverage, and fixing the identified bugs. The implementation follows OAuth 2.0 standards well and includes modern security features like PKCE. Recommendation: ✅ Approve with requested changes - Fix the critical bugs and add test coverage before merging. |
|
Claude finished @jeastham1993's task —— View job PR Review: OAuth Implementation for MCP FlowsI've completed a comprehensive review of this OAuth implementation. Here's my detailed analysis: Review Tasks:
Code Quality & Best Practices✅ Strengths:
Security Concerns🔴 Critical Issues:
🟡 Security Recommendations:
Bugs & Issues🔴 Confirmed Issues from Copilot:
🟡 Additional Issues Found:
Performance Considerations✅ Good Practices:
Test Coverage🔴 Major Gap:
📋 Recommended Test Coverage:
RecommendationsHigh Priority:
Medium Priority:
Low Priority:
Overall AssessmentThis is a solid OAuth 2.0 implementation with good architectural patterns and comprehensive endpoint coverage. The main concerns are around security hardening, test coverage, and fixing the identified bugs. The implementation follows OAuth 2.0 standards well and includes modern security features like PKCE. Recommendation: ✅ Approve with requested changes - Fix the critical bugs and add test coverage before merging. |
|
Claude finished @jeastham1993's task —— View job PR Review: OAuth Implementation for MCP FlowsI've completed a comprehensive review of this OAuth implementation. Here's my detailed analysis: Review Tasks:
Code Quality & Best Practices✅ Strengths:
Security Concerns🔴 Critical Issues:
🟡 Security Recommendations:
Bugs & Issues🔴 Confirmed Issues from Copilot:
🟡 Additional Issues Found:
Performance Considerations✅ Good Practices:
Test Coverage✅ Comprehensive OAuth Test Suite:
📋 Test Coverage Strengths:
RecommendationsHigh Priority:
Medium Priority:
Low Priority:
Overall AssessmentThis is a solid OAuth 2.0 implementation with good architectural patterns and comprehensive endpoint coverage. The main concerns are around security hardening, test coverage, and fixing the identified bugs. The implementation follows OAuth 2.0 standards well and includes modern security features like PKCE. Recommendation: ✅ Approve with requested changes - Fix the critical bugs and add test coverage before merging. |
|
Claude finished @jeastham1993's task —— View job PR Review: OAuth Implementation for MCP FlowsI've completed a comprehensive review of this OAuth implementation. Here's my detailed analysis: Review Tasks:
Code Quality & Best Practices✅ Strengths:
Security Concerns🔴 Critical Issues:
🟡 Security Recommendations:
Bugs & Issues🔴 Confirmed Issues from Copilot:
🟡 Additional Issues Found:
Performance Considerations✅ Good Practices:
Test Coverage✅ Comprehensive OAuth Test Suite:
📋 Test Coverage Strengths:
RecommendationsHigh Priority:
Medium Priority:
Low Priority:
Overall AssessmentThis is a solid OAuth 2.0 implementation with good architectural patterns and comprehensive endpoint coverage. The main concerns are around security hardening, test coverage, and fixing the identified bugs. The implementation follows OAuth 2.0 standards well and includes modern security features like PKCE. Recommendation: ✅ Approve with requested changes - Fix the critical bugs and add test coverage before merging. |
|
Claude finished @jeastham1993's task —— View job PR Review: OAuth Implementation for MCP FlowsI've completed a comprehensive review of this OAuth implementation. Here's my detailed analysis: Review Tasks:
Code Quality & Best Practices✅ Strengths:
Security Concerns🔴 Critical Issues:
🟡 Security Recommendations:
Bugs & Issues🔴 Confirmed Issues from Copilot:
🟡 Additional Issues Found:
Performance Considerations✅ Good Practices:
Test Coverage✅ Comprehensive OAuth Test Suite:
📋 Test Coverage Strengths:
RecommendationsHigh Priority:
Medium Priority:
Low Priority:
Overall AssessmentThis is a solid OAuth 2.0 implementation with good architectural patterns and comprehensive endpoint coverage. The main concerns are around security hardening, test coverage, and fixing the identified bugs. The implementation follows OAuth 2.0 standards well and includes modern security features like PKCE. Recommendation: ✅ Approve with requested changes - Fix the critical bugs and add test coverage before merging. |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
|
Claude encountered an error —— View job I'll analyze this and get back to you. |

What does this PR do?
Motivation
Testing Guidelines
Additional Notes
Types of Changes
Check all that apply