Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lint
  • Loading branch information
waleedlatif1 committed Mar 27, 2026
commit c52698da829342a022943ce5b28bbed4cb147f5d
9 changes: 9 additions & 0 deletions apps/sim/app/api/copilot/training/examples/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { createLogger } from '@sim/logger'
import { type NextRequest, NextResponse } from 'next/server'
import { z } from 'zod'
import {
authenticateCopilotRequestSessionOnly,
createUnauthorizedResponse,
} from '@/lib/copilot/request-helpers'
import { env } from '@/lib/core/config/env'

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

export async function POST(request: NextRequest) {
const { userId, isAuthenticated } = await authenticateCopilotRequestSessionOnly()
if (!isAuthenticated || !userId) {
return createUnauthorizedResponse()
}

const baseUrl = env.AGENT_INDEXER_URL
if (!baseUrl) {
logger.error('Missing AGENT_INDEXER_URL environment variable')
Expand Down
9 changes: 9 additions & 0 deletions apps/sim/app/api/copilot/training/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { createLogger } from '@sim/logger'
import { type NextRequest, NextResponse } from 'next/server'
import { z } from 'zod'
import {
authenticateCopilotRequestSessionOnly,
createUnauthorizedResponse,
} from '@/lib/copilot/request-helpers'
import { env } from '@/lib/core/config/env'

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

export async function POST(request: NextRequest) {
const { userId, isAuthenticated } = await authenticateCopilotRequestSessionOnly()
if (!isAuthenticated || !userId) {
return createUnauthorizedResponse()
}

try {
const baseUrl = env.AGENT_INDEXER_URL
if (!baseUrl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ export async function GET(
}

// Verify caller is either an org member or the invitee
const isInvitee =
session.user.email?.toLowerCase() === orgInvitation.email.toLowerCase()
const isInvitee = session.user.email?.toLowerCase() === orgInvitation.email.toLowerCase()

if (!isInvitee) {
const memberEntry = await db
Expand Down
6 changes: 0 additions & 6 deletions apps/sim/app/api/workflows/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
updateApiKeyLastUsed,
} from '@/lib/api-key/service'
import { type AuthResult, checkHybridAuth } from '@/lib/auth/hybrid'
import { env } from '@/lib/core/config/env'
import { authorizeWorkflowByWorkspacePermission, getWorkflowById } from '@/lib/workflows/utils'

const logger = createLogger('WorkflowMiddleware')
Expand Down Expand Up @@ -81,11 +80,6 @@ export async function validateWorkflowAccess(
}
}

const internalSecret = request.headers.get('X-Internal-Secret')
if (env.INTERNAL_API_SECRET && internalSecret === env.INTERNAL_API_SECRET) {
return { workflow }
}

let apiKeyHeader = null
for (const [key, value] of request.headers.entries()) {
if (key.toLowerCase() === 'x-api-key' && value) {
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/lib/auth/hybrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const BEARER_PREFIX = 'Bearer '
export function hasExternalApiCredentials(headers: Headers): boolean {
if (headers.has(API_KEY_HEADER)) return true
const auth = headers.get('authorization')
return auth !== null && auth.startsWith(BEARER_PREFIX)
return auth?.startsWith(BEARER_PREFIX)
Comment thread
waleedlatif1 marked this conversation as resolved.
Outdated
}

export interface AuthResult {
Expand Down
1 change: 1 addition & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading