Skip to content

Commit ce2ed79

Browse files
author
test
committed
fix(workflows): use AuthType enum in middleware auth checks
1 parent 3103042 commit ce2ed79

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ vi.mock('@/lib/api-key/service', () => ({
3030
}))
3131

3232
vi.mock('@/lib/auth/hybrid', () => ({
33+
AuthType: {
34+
SESSION: 'session',
35+
API_KEY: 'api_key',
36+
INTERNAL_JWT: 'internal_jwt',
37+
},
3338
checkHybridAuth: (...args: unknown[]) => mockCheckHybridAuth(...args),
3439
}))
3540

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
authenticateApiKeyFromHeader,
66
updateApiKeyLastUsed,
77
} from '@/lib/api-key/service'
8-
import { type AuthResult, checkHybridAuth } from '@/lib/auth/hybrid'
8+
import { type AuthResult, AuthType, checkHybridAuth } from '@/lib/auth/hybrid'
99
import { env } from '@/lib/core/config/env'
1010
import { authorizeWorkflowByWorkspacePermission, getWorkflowById } from '@/lib/workflows/utils'
1111

@@ -77,7 +77,7 @@ export async function validateWorkflowAccess(
7777
const workflow = workflowResult.workflow
7878

7979
if (
80-
auth.authType === 'api_key' &&
80+
auth.authType === AuthType.API_KEY &&
8181
auth.apiKeyType === 'workspace' &&
8282
auth.workspaceId !== workflow.workspaceId
8383
) {

0 commit comments

Comments
 (0)