@@ -18,6 +18,7 @@ async function createParticipantToken(
1818 } )
1919 . setProtectedHeader ( { alg : 'HS256' } )
2020 . setIssuedAt ( )
21+ . setIssuer ( process . env . APP_ORIGIN_AUTH || 'https://auth.klicker.com' )
2122 . setExpirationTime ( '1h' )
2223 . sign ( secret )
2324}
@@ -32,12 +33,13 @@ async function createInvalidToken(): Promise<string> {
3233 } )
3334 . setProtectedHeader ( { alg : 'HS256' } )
3435 . setIssuedAt ( )
36+ . setIssuer ( process . env . APP_ORIGIN_AUTH || 'https://auth.klicker.com' )
3537 . setExpirationTime ( '1h' )
3638 . sign ( secret )
3739}
3840
3941describe ( 'Public Endpoint Authentication' , ( ) => {
40- it ( 'should accept valid participant_token cookie' , async ( ) => {
42+ it ( 'should accept valid next-auth.participant-session-token cookie' , async ( ) => {
4143 const validToken = await createParticipantToken ( )
4244 const eventData = {
4345 action : AuditAction . PARTICIPANT_SUBMIT_RESPONSE ,
@@ -52,7 +54,7 @@ describe('Public Endpoint Authentication', () => {
5254 method : 'POST' ,
5355 headers : {
5456 'Content-Type' : 'application/json' ,
55- Cookie : `participant_token =${ validToken } ` ,
57+ Cookie : `next-auth.participant-session-token =${ validToken } ` ,
5658 } ,
5759 body : JSON . stringify ( eventData ) ,
5860 } )
@@ -81,7 +83,7 @@ describe('Public Endpoint Authentication', () => {
8183 expect ( result . error ) . toBe ( 'No cookies provided' )
8284 } )
8385
84- it ( 'should reject requests without participant_token cookie' , async ( ) => {
86+ it ( 'should reject requests without next-auth.participant-session-token cookie' , async ( ) => {
8587 const eventData = {
8688 action : AuditAction . PARTICIPANT_SUBMIT_RESPONSE ,
8789 }
@@ -97,7 +99,9 @@ describe('Public Endpoint Authentication', () => {
9799
98100 expect ( response . status ) . toBe ( 401 )
99101 const result = ( await response . json ( ) ) as any
100- expect ( result . error ) . toBe ( 'participant_token cookie required' )
102+ expect ( result . error ) . toBe (
103+ 'next-auth.participant-session-token cookie required'
104+ )
101105 } )
102106
103107 it ( 'should reject invalid/expired tokens' , async ( ) => {
@@ -110,7 +114,7 @@ describe('Public Endpoint Authentication', () => {
110114 method : 'POST' ,
111115 headers : {
112116 'Content-Type' : 'application/json' ,
113- Cookie : `participant_token =${ invalidToken } ` ,
117+ Cookie : `next-auth.participant-session-token =${ invalidToken } ` ,
114118 } ,
115119 body : JSON . stringify ( eventData ) ,
116120 } )
@@ -129,7 +133,7 @@ describe('Public Endpoint Authentication', () => {
129133 method : 'POST' ,
130134 headers : {
131135 'Content-Type' : 'application/json' ,
132- Cookie : 'participant_token =invalid-jwt-token' ,
136+ Cookie : 'next-auth.participant-session-token =invalid-jwt-token' ,
133137 } ,
134138 body : JSON . stringify ( eventData ) ,
135139 } )
@@ -168,7 +172,7 @@ describe('Public Event Filtering', () => {
168172 method : 'POST' ,
169173 headers : {
170174 'Content-Type' : 'application/json' ,
171- Cookie : `participant_token =${ validToken } ` ,
175+ Cookie : `next-auth.participant-session-token =${ validToken } ` ,
172176 } ,
173177 body : JSON . stringify ( eventData ) ,
174178 } )
@@ -198,7 +202,7 @@ describe('Public Event Filtering', () => {
198202 method : 'POST' ,
199203 headers : {
200204 'Content-Type' : 'application/json' ,
201- Cookie : `participant_token =${ validToken } ` ,
205+ Cookie : `next-auth.participant-session-token =${ validToken } ` ,
202206 } ,
203207 body : JSON . stringify ( eventData ) ,
204208 } )
@@ -236,7 +240,7 @@ describe('Public Event Context Injection', () => {
236240 method : 'POST' ,
237241 headers : {
238242 'Content-Type' : 'application/json' ,
239- Cookie : `participant_token =${ validToken } ` ,
243+ Cookie : `next-auth.participant-session-token =${ validToken } ` ,
240244 } ,
241245 body : JSON . stringify ( eventData ) ,
242246 } )
@@ -265,7 +269,7 @@ describe('Public Event Context Injection', () => {
265269 method : 'POST' ,
266270 headers : {
267271 'Content-Type' : 'application/json' ,
268- Cookie : `participant_token =${ tempToken } ` ,
272+ Cookie : `next-auth.participant-session-token =${ tempToken } ` ,
269273 } ,
270274 body : JSON . stringify ( eventData ) ,
271275 } )
@@ -289,7 +293,7 @@ describe('Public Event Data Validation', () => {
289293 method : 'POST' ,
290294 headers : {
291295 'Content-Type' : 'application/json' ,
292- Cookie : `participant_token =${ validToken } ` ,
296+ Cookie : `next-auth.participant-session-token =${ validToken } ` ,
293297 } ,
294298 body : JSON . stringify ( {
295299 // Missing action field
@@ -303,7 +307,7 @@ describe('Public Event Data Validation', () => {
303307 method : 'POST' ,
304308 headers : {
305309 'Content-Type' : 'application/json' ,
306- Cookie : `participant_token =${ validToken } ` ,
310+ Cookie : `next-auth.participant-session-token =${ validToken } ` ,
307311 } ,
308312 body : JSON . stringify ( { } ) ,
309313 } )
@@ -326,7 +330,7 @@ describe('Public Event Data Validation', () => {
326330 method : 'POST' ,
327331 headers : {
328332 'Content-Type' : 'application/json' ,
329- Cookie : `participant_token =${ validToken } ` ,
333+ Cookie : `next-auth.participant-session-token =${ validToken } ` ,
330334 } ,
331335 body : JSON . stringify ( eventData ) ,
332336 } )
@@ -348,7 +352,7 @@ describe('Public Event Data Validation', () => {
348352 method : 'POST' ,
349353 headers : {
350354 'Content-Type' : 'application/json' ,
351- Cookie : `participant_token =${ validToken } ` ,
355+ Cookie : `next-auth.participant-session-token =${ validToken } ` ,
352356 } ,
353357 body : JSON . stringify ( eventData ) ,
354358 } )
0 commit comments