-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix(elevenlabs): added internal auth helper for proxy routes #1732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Greptile Summary
This PR adds authentication to proxy routes using the checkHybridAuth helper, which supports three authentication methods: internal JWT tokens, session cookies, and request headers. The authentication check was added to all proxy endpoints (/api/proxy, /api/proxy/image, /api/proxy/tts, /api/proxy/tts/stream) to prevent unauthorized access.
Key Changes:
- Added
checkHybridAuthcall at the start of each proxy route handler withrequireWorkflowId: falseoption - Improved error response consistency in TTS routes by using
NextResponse.jsonformat throughout - Added error handling in
elevenlabs/tts.tsto properly handle error responses from the proxy - Removed
.concurrentflag from all tests to run them sequentially (addressing test flakiness) - Cleaned up unnecessary comments in proxy route file
Confidence Score: 5/5
- This PR is safe to merge with minimal risk
- The changes are straightforward security improvements that add authentication to previously unprotected proxy routes. The
checkHybridAuthhelper is well-tested and already used elsewhere in the codebase. The implementation is consistent across all proxy endpoints, and the test changes address concurrency issues. No breaking changes or risky logic modifications. - No files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/app/api/proxy/route.ts | 5/5 | Added checkHybridAuth call at the start of POST handler to authenticate requests; removed some comments |
| apps/sim/app/api/proxy/image/route.ts | 5/5 | Added checkHybridAuth call at the start of GET handler to authenticate image proxy requests |
| apps/sim/app/api/proxy/tts/route.ts | 5/5 | Added checkHybridAuth authentication; improved error responses by consistently using NextResponse.json format |
| apps/sim/app/api/proxy/tts/stream/route.ts | 5/5 | Added checkHybridAuth call at the start of POST handler to authenticate streaming TTS requests |
| apps/sim/tools/elevenlabs/tts.ts | 5/5 | Added error handling in transformResponse to check for errors in the response data and return appropriate error structure |
| apps/sim/tools/index.test.ts | 5/5 | Removed .concurrent flag from all test cases to run tests sequentially instead of concurrently |
Sequence Diagram
sequenceDiagram
participant Client
participant ProxyRoute as Proxy Route
participant HybridAuth as checkHybridAuth
participant AuthLayer as Authentication Layer
participant ToolExecution as Tool Execution
Client->>ProxyRoute: POST /api/proxy
ProxyRoute->>HybridAuth: Verify request
HybridAuth->>AuthLayer: Check internal token
alt Internal token present and validated
AuthLayer-->>HybridAuth: Returns user context from workflow
HybridAuth-->>ProxyRoute: Access granted
else Internal token not present or invalid
AuthLayer->>AuthLayer: Check session cookie
alt Session cookie found and verified
AuthLayer-->>HybridAuth: Returns user from session
HybridAuth-->>ProxyRoute: Access granted
else No session cookie
AuthLayer->>AuthLayer: Check request headers
alt Request headers verified
AuthLayer-->>HybridAuth: Returns user from headers
HybridAuth-->>ProxyRoute: Access granted
else No access method found
AuthLayer-->>HybridAuth: No authentication present
HybridAuth-->>ProxyRoute: Access denied
end
end
end
alt Access Denied
ProxyRoute-->>Client: 401 Unauthorized
else Access Granted
ProxyRoute->>ToolExecution: Execute tool with params
ToolExecution-->>ProxyRoute: Tool result
ProxyRoute-->>Client: 200 OK with result
end
8 files reviewed, no comments
* fix(elevenlabs): added internal auth helper for proxy routes * remove concurrent tests * build fix
Summary
Type of Change
Testing
Tested manually
Checklist