File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 6464 AWS_SECRET_ACCESS_KEY : " "
6565 BUILD_ENGINE_SECRETS_BUCKET : " "
6666 SCRIPTURE_EARTH_KEY : " "
67+ ORIGIN : " "
68+ API_ACCESS_TOKEN : " "
6769 steps :
6870 - uses : actions/checkout@v5
6971 - uses : actions/setup-node@v5
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import { trace } from '@opentelemetry/api';
22import type { Prisma } from '@prisma/client' ;
33import { type RequestEvent , error , redirect } from '@sveltejs/kit' ;
44import { jwtDecrypt } from 'jose' ;
5- import { createHash , randomUUID } from 'node:crypto' ;
5+ import { createHash , randomUUID , timingSafeEqual } from 'node:crypto' ;
66import { getAuthConnection } from './bullmq/queues' ;
77import { prisma } from './prisma' ;
88import { env as secrets } from '$env/dynamic/private' ;
@@ -102,7 +102,12 @@ export async function tryVerifyAPIToken(
102102 }
103103 const client = await prisma . client . findFirst ( { where : { access_token } } ) ;
104104 if ( ! client ) {
105- if ( access_token === secrets . API_ACCESS_TOKEN ) {
105+ if (
106+ timingSafeEqual (
107+ Buffer . from ( access_token , 'hex' ) ,
108+ Buffer . from ( secrets . API_ACCESS_TOKEN , 'hex' )
109+ )
110+ ) {
106111 return [ true , null ] ;
107112 }
108113 return [ false , ErrorResponse ( 403 , 'Invalid Access Token' ) ] ;
You can’t perform that action at this time.
0 commit comments