Skip to content

Commit cc0d2a0

Browse files
committed
fix(selectors): use checkSessionOrInternalAuth for UI-accessible routes
1 parent ea401e4 commit cc0d2a0

File tree

18 files changed

+43
-43
lines changed

18 files changed

+43
-43
lines changed

apps/sim/app/api/tools/confluence/attachment/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createLogger } from '@sim/logger'
22
import { type NextRequest, NextResponse } from 'next/server'
3-
import { checkInternalAuth } from '@/lib/auth/hybrid'
3+
import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid'
44
import { validateAlphanumericId, validateJiraCloudId } from '@/lib/core/security/input-validation'
55
import { getConfluenceCloudId } from '@/tools/confluence/utils'
66

@@ -11,7 +11,7 @@ export const dynamic = 'force-dynamic'
1111
// Delete an attachment
1212
export async function DELETE(request: NextRequest) {
1313
try {
14-
const auth = await checkInternalAuth(request)
14+
const auth = await checkSessionOrInternalAuth(request)
1515
if (!auth.success || !auth.userId) {
1616
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
1717
}

apps/sim/app/api/tools/confluence/attachments/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createLogger } from '@sim/logger'
22
import { type NextRequest, NextResponse } from 'next/server'
3-
import { checkInternalAuth } from '@/lib/auth/hybrid'
3+
import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid'
44
import { validateAlphanumericId, validateJiraCloudId } from '@/lib/core/security/input-validation'
55
import { getConfluenceCloudId } from '@/tools/confluence/utils'
66

@@ -11,7 +11,7 @@ export const dynamic = 'force-dynamic'
1111
// List attachments on a page
1212
export async function GET(request: NextRequest) {
1313
try {
14-
const auth = await checkInternalAuth(request)
14+
const auth = await checkSessionOrInternalAuth(request)
1515
if (!auth.success || !auth.userId) {
1616
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
1717
}

apps/sim/app/api/tools/confluence/comment/route.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createLogger } from '@sim/logger'
22
import { type NextRequest, NextResponse } from 'next/server'
33
import { z } from 'zod'
4-
import { checkInternalAuth } from '@/lib/auth/hybrid'
4+
import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid'
55
import { validateAlphanumericId, validateJiraCloudId } from '@/lib/core/security/input-validation'
66
import { getConfluenceCloudId } from '@/tools/confluence/utils'
77

@@ -49,7 +49,7 @@ const deleteCommentSchema = z
4949
// Update a comment
5050
export async function PUT(request: NextRequest) {
5151
try {
52-
const auth = await checkInternalAuth(request)
52+
const auth = await checkSessionOrInternalAuth(request)
5353
if (!auth.success || !auth.userId) {
5454
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
5555
}
@@ -136,7 +136,7 @@ export async function PUT(request: NextRequest) {
136136
// Delete a comment
137137
export async function DELETE(request: NextRequest) {
138138
try {
139-
const auth = await checkInternalAuth(request)
139+
const auth = await checkSessionOrInternalAuth(request)
140140
if (!auth.success || !auth.userId) {
141141
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
142142
}

apps/sim/app/api/tools/confluence/comments/route.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createLogger } from '@sim/logger'
22
import { type NextRequest, NextResponse } from 'next/server'
3-
import { checkInternalAuth } from '@/lib/auth/hybrid'
3+
import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid'
44
import { validateAlphanumericId, validateJiraCloudId } from '@/lib/core/security/input-validation'
55
import { getConfluenceCloudId } from '@/tools/confluence/utils'
66

@@ -11,7 +11,7 @@ export const dynamic = 'force-dynamic'
1111
// Create a comment
1212
export async function POST(request: NextRequest) {
1313
try {
14-
const auth = await checkInternalAuth(request)
14+
const auth = await checkSessionOrInternalAuth(request)
1515
if (!auth.success || !auth.userId) {
1616
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
1717
}
@@ -94,7 +94,7 @@ export async function POST(request: NextRequest) {
9494
// List comments on a page
9595
export async function GET(request: NextRequest) {
9696
try {
97-
const auth = await checkInternalAuth(request)
97+
const auth = await checkSessionOrInternalAuth(request)
9898
if (!auth.success || !auth.userId) {
9999
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
100100
}

apps/sim/app/api/tools/confluence/create-page/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createLogger } from '@sim/logger'
22
import { type NextRequest, NextResponse } from 'next/server'
3-
import { checkInternalAuth } from '@/lib/auth/hybrid'
3+
import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid'
44
import { validateAlphanumericId, validateJiraCloudId } from '@/lib/core/security/input-validation'
55
import { getConfluenceCloudId } from '@/tools/confluence/utils'
66

@@ -10,7 +10,7 @@ export const dynamic = 'force-dynamic'
1010

1111
export async function POST(request: NextRequest) {
1212
try {
13-
const auth = await checkInternalAuth(request)
13+
const auth = await checkSessionOrInternalAuth(request)
1414
if (!auth.success || !auth.userId) {
1515
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
1616
}

apps/sim/app/api/tools/confluence/labels/route.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createLogger } from '@sim/logger'
22
import { type NextRequest, NextResponse } from 'next/server'
3-
import { checkInternalAuth } from '@/lib/auth/hybrid'
3+
import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid'
44
import { validateAlphanumericId, validateJiraCloudId } from '@/lib/core/security/input-validation'
55
import { getConfluenceCloudId } from '@/tools/confluence/utils'
66

@@ -11,7 +11,7 @@ export const dynamic = 'force-dynamic'
1111
// Add a label to a page
1212
export async function POST(request: NextRequest) {
1313
try {
14-
const auth = await checkInternalAuth(request)
14+
const auth = await checkSessionOrInternalAuth(request)
1515
if (!auth.success || !auth.userId) {
1616
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
1717
}
@@ -95,7 +95,7 @@ export async function POST(request: NextRequest) {
9595
// List labels on a page
9696
export async function GET(request: NextRequest) {
9797
try {
98-
const auth = await checkInternalAuth(request)
98+
const auth = await checkSessionOrInternalAuth(request)
9999
if (!auth.success || !auth.userId) {
100100
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
101101
}

apps/sim/app/api/tools/confluence/page/route.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createLogger } from '@sim/logger'
22
import { type NextRequest, NextResponse } from 'next/server'
33
import { z } from 'zod'
4-
import { checkInternalAuth } from '@/lib/auth/hybrid'
4+
import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid'
55
import { validateAlphanumericId, validateJiraCloudId } from '@/lib/core/security/input-validation'
66
import { getConfluenceCloudId } from '@/tools/confluence/utils'
77

@@ -76,7 +76,7 @@ const deletePageSchema = z
7676

7777
export async function POST(request: NextRequest) {
7878
try {
79-
const auth = await checkInternalAuth(request)
79+
const auth = await checkSessionOrInternalAuth(request)
8080
if (!auth.success || !auth.userId) {
8181
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
8282
}
@@ -152,7 +152,7 @@ export async function POST(request: NextRequest) {
152152

153153
export async function PUT(request: NextRequest) {
154154
try {
155-
const auth = await checkInternalAuth(request)
155+
const auth = await checkSessionOrInternalAuth(request)
156156
if (!auth.success || !auth.userId) {
157157
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
158158
}
@@ -261,7 +261,7 @@ export async function PUT(request: NextRequest) {
261261

262262
export async function DELETE(request: NextRequest) {
263263
try {
264-
const auth = await checkInternalAuth(request)
264+
const auth = await checkSessionOrInternalAuth(request)
265265
if (!auth.success || !auth.userId) {
266266
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
267267
}

apps/sim/app/api/tools/confluence/pages/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createLogger } from '@sim/logger'
22
import { type NextRequest, NextResponse } from 'next/server'
3-
import { checkInternalAuth } from '@/lib/auth/hybrid'
3+
import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid'
44
import { validateJiraCloudId } from '@/lib/core/security/input-validation'
55
import { getConfluenceCloudId } from '@/tools/confluence/utils'
66

@@ -11,7 +11,7 @@ export const dynamic = 'force-dynamic'
1111
// List pages or search pages
1212
export async function POST(request: NextRequest) {
1313
try {
14-
const auth = await checkInternalAuth(request)
14+
const auth = await checkSessionOrInternalAuth(request)
1515
if (!auth.success || !auth.userId) {
1616
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
1717
}

apps/sim/app/api/tools/confluence/search/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createLogger } from '@sim/logger'
22
import { type NextRequest, NextResponse } from 'next/server'
3-
import { checkInternalAuth } from '@/lib/auth/hybrid'
3+
import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid'
44
import { validateJiraCloudId } from '@/lib/core/security/input-validation'
55
import { getConfluenceCloudId } from '@/tools/confluence/utils'
66

@@ -10,7 +10,7 @@ const logger = createLogger('Confluence Search')
1010

1111
export async function POST(request: NextRequest) {
1212
try {
13-
const auth = await checkInternalAuth(request)
13+
const auth = await checkSessionOrInternalAuth(request)
1414
if (!auth.success || !auth.userId) {
1515
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
1616
}

apps/sim/app/api/tools/confluence/space/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createLogger } from '@sim/logger'
22
import { type NextRequest, NextResponse } from 'next/server'
3-
import { checkInternalAuth } from '@/lib/auth/hybrid'
3+
import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid'
44
import { validateAlphanumericId, validateJiraCloudId } from '@/lib/core/security/input-validation'
55
import { getConfluenceCloudId } from '@/tools/confluence/utils'
66

@@ -11,7 +11,7 @@ export const dynamic = 'force-dynamic'
1111
// Get a specific space
1212
export async function GET(request: NextRequest) {
1313
try {
14-
const auth = await checkInternalAuth(request)
14+
const auth = await checkSessionOrInternalAuth(request)
1515
if (!auth.success || !auth.userId) {
1616
return NextResponse.json({ error: auth.error || 'Unauthorized' }, { status: 401 })
1717
}

0 commit comments

Comments
 (0)