@thinkingcat/auth-utils 1.0.41 → 1.0.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +25 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -461,11 +461,11 @@ async function createAuthResponse(accessToken, secret, options) {
|
|
|
461
461
|
? NextResponseClass.redirect(new URL(redirectPath, req.url), { status: 302 })
|
|
462
462
|
: NextResponseClass.json({ success: true, message: text || 'Authentication successful' }, { status: 200 });
|
|
463
463
|
// 4. NextAuth 세션 쿠키 생성 (Edge Runtime에서도 작동하도록 encodeNextAuthToken 사용)
|
|
464
|
+
const nextAuthCookieName = isProduction
|
|
465
|
+
? '__Secure-next-auth.session-token'
|
|
466
|
+
: 'next-auth.session-token';
|
|
464
467
|
try {
|
|
465
468
|
const nextAuthToken = await encodeNextAuthToken(jwt, secret);
|
|
466
|
-
const nextAuthCookieName = isProduction
|
|
467
|
-
? '__Secure-next-auth.session-token'
|
|
468
|
-
: 'next-auth.session-token';
|
|
469
469
|
const cookieOptions = {
|
|
470
470
|
httpOnly: true,
|
|
471
471
|
secure: isProduction,
|
|
@@ -503,6 +503,11 @@ async function createAuthResponse(accessToken, secret, options) {
|
|
|
503
503
|
});
|
|
504
504
|
}
|
|
505
505
|
debugLog('createAuthResponse', 'Custom tokens set successfully');
|
|
506
|
+
console.log('[createAuthResponse] All cookies set:', {
|
|
507
|
+
nextAuthCookie: nextAuthCookieName,
|
|
508
|
+
accessTokenCookie: `${cookiePrefix}_access_token`,
|
|
509
|
+
refreshTokenCookie: refreshToken ? `${cookiePrefix}_refresh_token` : 'none',
|
|
510
|
+
});
|
|
506
511
|
return response;
|
|
507
512
|
}
|
|
508
513
|
// ============================================================================
|
|
@@ -1544,8 +1549,14 @@ async function handleMiddleware(req, config, options) {
|
|
|
1544
1549
|
// 2. 루트 경로 처리 - SSO 토큰 처리 (인증 체크보다 먼저!)
|
|
1545
1550
|
if (pathname === '/') {
|
|
1546
1551
|
const tokenParam = req.nextUrl.searchParams.get('token');
|
|
1552
|
+
console.log('[handleMiddleware] Root path check:', {
|
|
1553
|
+
pathname,
|
|
1554
|
+
hasTokenParam: !!tokenParam,
|
|
1555
|
+
tokenLength: tokenParam?.length || 0,
|
|
1556
|
+
});
|
|
1547
1557
|
if (tokenParam) {
|
|
1548
1558
|
debugLog('handleMiddleware', 'Processing SSO token from query parameter');
|
|
1559
|
+
console.log('[handleMiddleware] Processing SSO token from query parameter');
|
|
1549
1560
|
try {
|
|
1550
1561
|
// 1. 토큰 검증
|
|
1551
1562
|
const tokenResult = await verifyToken(tokenParam, secret);
|
|
@@ -1590,6 +1601,13 @@ async function handleMiddleware(req, config, options) {
|
|
|
1590
1601
|
// 4. 자체 토큰 생성 및 쿠키 설정
|
|
1591
1602
|
const redirectPath = config.rolePaths[tokenRole] || config.rolePaths[defaultRole] || '/admin';
|
|
1592
1603
|
debugLog('handleMiddleware', `Creating auth response, redirect to: ${redirectPath}`);
|
|
1604
|
+
console.log('[handleMiddleware] Creating auth response:', {
|
|
1605
|
+
redirectPath,
|
|
1606
|
+
hasRefreshToken: !!refreshToken,
|
|
1607
|
+
cookiePrefix,
|
|
1608
|
+
isProduction,
|
|
1609
|
+
cookieDomain,
|
|
1610
|
+
});
|
|
1593
1611
|
const response = await createAuthResponse(tokenParam, secret, {
|
|
1594
1612
|
req,
|
|
1595
1613
|
refreshToken: refreshToken || undefined,
|
|
@@ -1601,6 +1619,10 @@ async function handleMiddleware(req, config, options) {
|
|
|
1601
1619
|
serviceId,
|
|
1602
1620
|
licenseKey: options.licenseKey,
|
|
1603
1621
|
});
|
|
1622
|
+
console.log('[handleMiddleware] Auth response created, cookies set:', {
|
|
1623
|
+
hasResponse: !!response,
|
|
1624
|
+
cookieNames: ['renton_access_token', 'renton_refresh_token', isProduction ? '__Secure-next-auth.session-token' : 'next-auth.session-token'],
|
|
1625
|
+
});
|
|
1604
1626
|
return response;
|
|
1605
1627
|
}
|
|
1606
1628
|
catch (error) {
|
package/package.json
CHANGED