-
Notifications
You must be signed in to change notification settings - Fork 3.3k
fix(security): add authentication to tool API routes #3028
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. |
Greptile OverviewGreptile SummaryAdded Key Changes
Implementation PatternAll routes now follow a consistent authentication pattern at the start of request handlers: const auth = await checkInternalAuth(request)
if (!auth.success || !auth.userId) {
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
}The
Test CoverageAdded comprehensive test suite for OAuth token route covering:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant ToolAPI as Tool API Route
participant Auth as checkInternalAuth
participant Verifier as JWT Verifier
participant Service as External Service
Client->>ToolAPI: POST request
ToolAPI->>Auth: Check authentication
alt Missing internal JWT
Auth-->>ToolAPI: Auth failed
ToolAPI-->>Client: 401 Error
end
alt Wrong auth method used
Auth-->>ToolAPI: Method not allowed
ToolAPI-->>Client: 401 Error
end
Auth->>Verifier: Verify JWT
Verifier-->>Auth: Valid
Auth-->>ToolAPI: Authenticated with userId
ToolAPI->>Service: Execute operation
Service-->>ToolAPI: Result
ToolAPI-->>Client: 200 Success
|
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.
No files reviewed, no comments
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.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
Summary
checkInternalAuthto all tool API routes that were missing authenticationType of Change
Testing
Tested manually - unauthenticated requests now return 401
Checklist