diff --git a/app/api/auth/options.ts b/app/api/auth/options.ts index 5c84cf6..e03ea83 100644 --- a/app/api/auth/options.ts +++ b/app/api/auth/options.ts @@ -192,6 +192,7 @@ async function refreshAccessToken(token: ExtendedJWT) { } export const authOptions: NextAuthOptions = { + debug: false, // Désactive les logs NextAuth en mode debug pour la sécurité providers: [ KeycloakProvider({ clientId: getRequiredEnvVar("KEYCLOAK_CLIENT_ID"), @@ -358,7 +359,7 @@ export const authOptions: NextAuthOptions = { // If we recently failed, return error immediately (cooldown active) if (timeSinceFailure < REFRESH_COOLDOWN_MS) { logger.debug('Refresh cooldown active, skipping refresh attempt', { - userId, + userIdHash: Buffer.from(userId).toString('base64').slice(0, 12), timeSinceFailure, cooldownRemaining: REFRESH_COOLDOWN_MS - timeSinceFailure, }); @@ -431,7 +432,7 @@ export const authOptions: NextAuthOptions = { cleanupRefreshCooldown(); // Prevent memory leak logger.info("Keycloak session invalidated, setting cooldown", { - userId, + userIdHash: Buffer.from(userId).toString('base64').slice(0, 12), cooldownMs: REFRESH_COOLDOWN_MS, }); @@ -550,12 +551,11 @@ export const authOptions: NextAuthOptions = { signIn: '/signin', error: '/signin', }, - debug: process.env.NODE_ENV === 'development', // Add error handling events events: { async signIn({ user, account, profile }) { logger.info('[NEXTAUTH] Sign-in event', { - userId: user?.id, + userIdHash: user?.id ? Buffer.from(user.id).toString('base64').slice(0, 12) : null, emailPresent: !!user?.email, provider: account?.provider, }); diff --git a/app/api/courrier/unread-counts/route.ts b/app/api/courrier/unread-counts/route.ts index 0199ba2..37ba74b 100644 --- a/app/api/courrier/unread-counts/route.ts +++ b/app/api/courrier/unread-counts/route.ts @@ -220,8 +220,7 @@ async function fetchUnreadCounts(userId: string): Promise