fix(internal-req): add internal token to server side#1700
Merged
icecrasher321 merged 1 commit intostagingfrom Oct 21, 2025
Merged
fix(internal-req): add internal token to server side#1700icecrasher321 merged 1 commit intostagingfrom
icecrasher321 merged 1 commit intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
There was a problem hiding this comment.
Greptile Overview
Summary
Added internal JWT authentication for server-side tool execution to enable secure communication between workflow execution engine and internal API endpoints.
Key Changes:
- Modified
handleInternalRequestto accept optionalexecutionContextparameter - Added
workflowIdas query parameter to internal requests when executing server-side - Integrated
generateInternalToken()to create signed JWT for server-side requests - Set
Authorization: Bearerheader with internal JWT whentypeof window === 'undefined' - Updated OAuth token fetch logic to include internal JWT for server-side calls
Integration:
The authentication flow integrates with the existing checkHybridAuth() system in lib/auth/hybrid.ts, which verifies the JWT signature and extracts workflowId to determine the workflow owner's userId for proper authorization context.
Confidence Score: 4/5
- This PR is safe to merge with minor testing recommended
- The implementation correctly integrates internal JWT authentication for server-side tool requests, following established patterns in the codebase. The code properly checks for server-side execution, generates signed JWTs, and passes workflowId for user context resolution. Error handling is in place for token generation failures. However, the PR description is incomplete ('IN PROGRESS') and there's no indication of testing coverage for this authentication flow.
- No files require special attention. The changes are well-contained and follow existing authentication patterns.
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| apps/sim/tools/index.ts | 4/5 | Added internal JWT token authentication for server-side tool requests via Authorization header and workflowId query parameter |
Sequence Diagram
sequenceDiagram
participant Tool as executeTool()
participant Handler as handleInternalRequest()
participant AuthSvc as generateInternalToken()
participant API as Internal API Route
participant HybridAuth as checkHybridAuth()
Tool->>Tool: Check if server-side
Tool->>Handler: Pass executionContext with workflowId
Handler->>Handler: Build URL with workflowId query param
Handler->>AuthSvc: Generate JWT
AuthSvc-->>Handler: Return JWT
Handler->>Handler: Add to headers
Handler->>API: HTTP request
API->>HybridAuth: Check headers
HybridAuth->>HybridAuth: Verify JWT
HybridAuth->>HybridAuth: Extract workflowId
HybridAuth->>HybridAuth: Lookup userId
HybridAuth-->>API: Auth success
API-->>Handler: Response
Handler-->>Tool: ToolResponse
1 file reviewed, no comments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Internal Request function needs to add internal token since we moved to calling routes for some tools like slack send message and telegram
Type of Change
Testing
Tested manually with @aadamgough
Checklist