You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Generate tokenconstcsrfToken=crypto.randomBytes(32).toString('hex');session.csrfToken=csrfToken;// Validate on POSTif(req.body.csrf!==session.csrfToken){thrownewForbiddenError('Invalid CSRF token');}
Secrets Management
// NEVER in codeconstAPI_KEY='sk-abc123...';// Environment variablesconstAPI_KEY=process.env.API_KEY;// Secrets manager (production)constsecret=awaitsecretsManager.getSecret('api-key');
// Events to loglogger.security({event: 'login_failed',ip: req.ip,email: req.body.email,reason: 'invalid_password',timestamp: newDate().toISOString()});// Never log// - Passwords// - Full credit card numbers// - Session tokens// - Personal data (in production)