Authentication
Auktiva uses NextAuth.js v4 for authentication, providing secure session management with credentials-based login.
Configuration
Required Environment Variables
# Secret key for encrypting sessions
AUTH_SECRET="your-secret-key-here"
# Base URL of your application
AUTH_URL="http://localhost:3000"Generating AUTH_SECRET
Always generate a unique, random secret for production:
# Using OpenSSL
openssl rand -base64 32
# Using Node.js
node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"Never use the example secret in production. Always generate a unique value.
How It Works
Registration
- User submits email, name, and password
- Password is hashed using bcrypt (10 rounds)
- User record is created in the database
- User is automatically logged in
Login
- User submits email and password
- Password is verified against stored hash
- Session is created and stored in database
- Session cookie is set in browser
Sessions
- Sessions are stored in the database (
sessionstable) - Session token is stored in an HTTP-only cookie
- Sessions expire after 30 days by default
Security Features
- Password hashing with bcrypt
- CSRF protection via NextAuth
- HTTP-only cookies for session tokens
- Database-stored sessions for security
Session Data
The session object contains:
{
user: {
id: string; // User's database ID
name: string; // User's display name
email: string; // User's email address
},
expires: string; // Session expiration date
}Last updated on