This document provides detailed instructions for configuring the security features of the Thiasil application, including admin authentication, environment variables, and deployment security.
The application uses bcrypt with salt rounds for secure password hashing. Never use plain text passwords.
Use the provided script to generate a secure password hash:
node scripts/generate-admin-hash.js YOUR_SECURE_PASSWORDRequirements for secure passwords:
- Minimum 8 characters
- Mix of uppercase, lowercase, numbers, and symbols
- Avoid common words or patterns
- Don't reuse passwords from other services
Local Development (.env.local):
ADMIN_USERNAME=admin
ADMIN_PASSWORD_HASH=$2b$12$[your_generated_hash_here]Production/Vercel:
- Go to Vercel Dashboard → Project Settings → Environment Variables
- Add variables:
- Key:
ADMIN_USERNAME, Value:admin - Key:
ADMIN_PASSWORD_HASH, Value:$2b$12$[your_generated_hash_here]
- Key:
Test your configuration:
- Start the development server:
npm run dev - Navigate to
/admin - Log in with your credentials
- Verify access to admin dashboard
| Variable | Description | Example |
|---|---|---|
ADMIN_USERNAME |
Admin login username | admin |
ADMIN_PASSWORD_HASH |
bcrypt hash of admin password | $2b$12$... |
| Variable | Description | Default |
|---|---|---|
NODE_ENV |
Environment type | development |
NEXT_REACT_COMPILER |
Enable React compiler | false |
- bcrypt hashing with 12 salt rounds
- Rate limiting on all admin endpoints
- Session validation for admin operations
- Failed login attempt logging
- Rate limiting: 10 requests per 5-minute window
- Input validation on all endpoints
- Request sanitization to prevent injection attacks
- Error handling without information disclosure
- MIME type validation against file extensions
- File size limits (configurable, default 10MB)
- Filename sanitization to prevent directory traversal
- Content scanning for malicious files
- X-Content-Type-Options:
nosniff - X-Frame-Options:
DENY - X-XSS-Protection:
1; mode=block - Referrer-Policy:
strict-origin-when-cross-origin - Cache-Control:
no-storefor API routes
- Environment Variables: Set in Vercel dashboard, not in code
- Domain Security: Use HTTPS only (enforced by Vercel)
- Edge Functions: API routes run on Vercel Edge for security
- Static Assets: Served via Vercel CDN with security headers
Before deploying to production:
- Admin password hash is set in environment variables
- No plain text passwords in code or config files
-
.env.localis in.gitignore(never committed) - All API endpoints have rate limiting
- File uploads are validated and sanitized
- Security headers are configured
- Error messages don't expose sensitive information
- Admin access is logged and monitored
- Failed login attempts with IP and timestamp
- Successful admin operations with user and action
- Rate limit violations with IP tracking
- File upload attempts and validations
- API errors and security violations
Monitor these patterns for security issues:
- Multiple failed login attempts from same IP
- Unusual admin activity patterns
- High rate of API errors or rate limit hits
- File upload rejections or suspicious files
-
Immediate Actions:
- Change admin password immediately
- Regenerate password hash with new password
- Update environment variables in all deployments
- Review recent admin activity logs
-
Investigation:
- Check access logs for unusual patterns
- Review file uploads for malicious content
- Verify no unauthorized changes to data
- Check for data exfiltration attempts
-
Recovery:
- Restore from clean backup if necessary
- Implement additional security measures
- Update incident response procedures
- Document lessons learned
- Never log passwords or sensitive data
- Use parameterized queries for database operations
- Validate all inputs on both client and server
- Implement proper error handling without information disclosure
- Keep dependencies updated for security patches
- Use strong passwords and change them regularly
- Monitor admin access logs for suspicious activity
- Keep backups secure and test restore procedures
- Limit admin access to necessary personnel only
- Use VPN or secure networks for admin operations
This security configuration helps meet common compliance requirements:
- Data Protection: Secure password storage and access controls
- Access Logging: Complete audit trail of admin operations
- Input Validation: Protection against injection attacks
- Error Handling: No sensitive information disclosure
- Encryption: Secure password hashing with industry standards
For security-related questions or to report vulnerabilities:
- Internal Issues: Check logs and configuration first
- Security Updates: Follow the REFACTOR.md checklist
- Vulnerabilities: Document and address according to priority levels
- Questions: Refer to this guide and Next.js security documentation
Last Updated: 2025-07-03
Security Level: Production Ready