File tree Expand file tree Collapse file tree 1 file changed +11
-11
lines changed
Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -143,7 +143,16 @@ export async function checkSessionOrInternalAuth(
143143 options : { requireWorkflowId ?: boolean } = { }
144144) : Promise < AuthResult > {
145145 try {
146- // 1. Check for internal JWT token first
146+ // 1. Reject API keys first
147+ const apiKeyHeader = request . headers . get ( 'x-api-key' )
148+ if ( apiKeyHeader ) {
149+ return {
150+ success : false ,
151+ error : 'API key access not allowed for this endpoint' ,
152+ }
153+ }
154+
155+ // 2. Check for internal JWT token
147156 const authHeader = request . headers . get ( 'authorization' )
148157 if ( authHeader ?. startsWith ( 'Bearer ' ) ) {
149158 const token = authHeader . split ( ' ' ) [ 1 ]
@@ -216,7 +225,7 @@ export async function checkSessionOrInternalAuth(
216225 }
217226 }
218227
219- // 2 . Try session auth (for web UI)
228+ // 3 . Try session auth (for web UI)
220229 const session = await getSession ( )
221230 if ( session ?. user ?. id ) {
222231 return {
@@ -226,15 +235,6 @@ export async function checkSessionOrInternalAuth(
226235 }
227236 }
228237
229- // 3. Explicitly reject API key
230- const apiKeyHeader = request . headers . get ( 'x-api-key' )
231- if ( apiKeyHeader ) {
232- return {
233- success : false ,
234- error : 'API key access not allowed for this endpoint' ,
235- }
236- }
237-
238238 return {
239239 success : false ,
240240 error : 'Authentication required - provide session or internal JWT' ,
You can’t perform that action at this time.
0 commit comments