Skip to content

Commit c52698d

Browse files
committed
lint
1 parent a3f48e9 commit c52698d

File tree

6 files changed

+21
-9
lines changed

6 files changed

+21
-9
lines changed

apps/sim/app/api/copilot/training/examples/route.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { createLogger } from '@sim/logger'
22
import { type NextRequest, NextResponse } from 'next/server'
33
import { z } from 'zod'
4+
import {
5+
authenticateCopilotRequestSessionOnly,
6+
createUnauthorizedResponse,
7+
} from '@/lib/copilot/request-helpers'
48
import { env } from '@/lib/core/config/env'
59

610
const logger = createLogger('CopilotTrainingExamplesAPI')
@@ -16,6 +20,11 @@ const TrainingExampleSchema = z.object({
1620
})
1721

1822
export async function POST(request: NextRequest) {
23+
const { userId, isAuthenticated } = await authenticateCopilotRequestSessionOnly()
24+
if (!isAuthenticated || !userId) {
25+
return createUnauthorizedResponse()
26+
}
27+
1928
const baseUrl = env.AGENT_INDEXER_URL
2029
if (!baseUrl) {
2130
logger.error('Missing AGENT_INDEXER_URL environment variable')

apps/sim/app/api/copilot/training/route.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { createLogger } from '@sim/logger'
22
import { type NextRequest, NextResponse } from 'next/server'
33
import { z } from 'zod'
4+
import {
5+
authenticateCopilotRequestSessionOnly,
6+
createUnauthorizedResponse,
7+
} from '@/lib/copilot/request-helpers'
48
import { env } from '@/lib/core/config/env'
59

610
const logger = createLogger('CopilotTrainingAPI')
@@ -22,6 +26,11 @@ const TrainingDataSchema = z.object({
2226
})
2327

2428
export async function POST(request: NextRequest) {
29+
const { userId, isAuthenticated } = await authenticateCopilotRequestSessionOnly()
30+
if (!isAuthenticated || !userId) {
31+
return createUnauthorizedResponse()
32+
}
33+
2534
try {
2635
const baseUrl = env.AGENT_INDEXER_URL
2736
if (!baseUrl) {

apps/sim/app/api/organizations/[id]/invitations/[invitationId]/route.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ export async function GET(
6262
}
6363

6464
// Verify caller is either an org member or the invitee
65-
const isInvitee =
66-
session.user.email?.toLowerCase() === orgInvitation.email.toLowerCase()
65+
const isInvitee = session.user.email?.toLowerCase() === orgInvitation.email.toLowerCase()
6766

6867
if (!isInvitee) {
6968
const memberEntry = await db

apps/sim/app/api/workflows/middleware.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import {
66
updateApiKeyLastUsed,
77
} from '@/lib/api-key/service'
88
import { type AuthResult, checkHybridAuth } from '@/lib/auth/hybrid'
9-
import { env } from '@/lib/core/config/env'
109
import { authorizeWorkflowByWorkspacePermission, getWorkflowById } from '@/lib/workflows/utils'
1110

1211
const logger = createLogger('WorkflowMiddleware')
@@ -81,11 +80,6 @@ export async function validateWorkflowAccess(
8180
}
8281
}
8382

84-
const internalSecret = request.headers.get('X-Internal-Secret')
85-
if (env.INTERNAL_API_SECRET && internalSecret === env.INTERNAL_API_SECRET) {
86-
return { workflow }
87-
}
88-
8983
let apiKeyHeader = null
9084
for (const [key, value] of request.headers.entries()) {
9185
if (key.toLowerCase() === 'x-api-key' && value) {

apps/sim/lib/auth/hybrid.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const BEARER_PREFIX = 'Bearer '
2525
export function hasExternalApiCredentials(headers: Headers): boolean {
2626
if (headers.has(API_KEY_HEADER)) return true
2727
const auth = headers.get('authorization')
28-
return auth !== null && auth.startsWith(BEARER_PREFIX)
28+
return auth?.startsWith(BEARER_PREFIX)
2929
}
3030

3131
export interface AuthResult {

bun.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)