local (recommended), password, and none. Choose the mode that fits your deployment scenario.
Authentication Modes Overview
| Mode | SPARKLYTICS_AUTH | First-Run UX | Best For |
|---|---|---|---|
| Local (recommended) | local | /setup page once, then /login | Production self-hosted deployments |
| Single password | password | Direct /login with env password | Simple single-user setups |
| Open (no auth) | none | Dashboard opens directly | Local dev behind trusted network |
The authentication mode cannot be changed after initial setup without clearing the database. Choose carefully before first launch.
Local Auth Mode (Recommended)
Best for: Production self-hosted deployments where you want secure password storage and the ability to change credentials without redeploying.How It Works
- First visit to
/dashboardredirects to/setup - Admin creates a password (stored hashed with Argon2id)
- Subsequent visits require login at
/login - Password is stored in DuckDB, not in environment variables
Configuration
First Launch Flow
Create admin password
Enter a password (minimum 12 characters recommended). Click Create Account.Password requirements:
- At least 1 character long (12+ recommended)
- Cannot be only whitespace
Password Requirements
- Minimum length: 1 character (12+ strongly recommended)
- Cannot be whitespace-only
- Stored hashed with Argon2id (64 MB memory cost by default)
Advanced: Argon2 Tuning
Argon2id memory cost in KB (64 MB default).Higher values increase security against brute-force attacks but use more RAM during login/setup.
Changing Your Password
Currently, password changes require database access:A dashboard password change feature is planned for v1.1.
Password Mode
Best for: Simple single-user deployments where you’re comfortable storing the password in environment variables.How It Works
- Password is set via
SPARKLYTICS_PASSWORDenvironment variable - No setup page — dashboard redirects directly to
/login - All logins use the environment variable password
- To change password, update env var and restart
Configuration
Docker Example
Security Considerations
- Store
SPARKLYTICS_PASSWORDsecurely (use Docker secrets, vault, or encrypted env files) - Never commit
.envfiles with passwords to version control - Use a strong password (12+ characters, mixed case, numbers, symbols)
Changing the Password
- Update
SPARKLYTICS_PASSWORDin your environment/config - Restart Sparklytics
- Existing sessions remain valid until they expire (
SPARKLYTICS_SESSION_DAYS)
None Mode (Development Only)
Best for: Local development when running onlocalhost behind a trusted network.
How It Works
- No login or setup screens
/dashboardopens directly/api/auth/statusendpoint returns404(not registered)- All dashboard routes are accessible without authentication
Configuration
Docker Example
When to Use None Mode
- Local development on
localhost - Running behind another authentication layer (OAuth proxy, VPN, etc.)
- Testing integrations where login flow is cumbersome
When NOT to Use None Mode
- Production deployments
- Any server accessible from the internet
- Shared development environments
Session Management
Session Lifetime
JWT session cookie lifetime in days (1-30).Applies to both
local and password modes.Secure Cookies
Controls the
Secure flag on session cookies.true: Cookies sent only over HTTPS (required for production)false: Cookies sent over HTTP (localhost development only)
Cookie Attributes
Sparklytics session cookies use these security flags:HttpOnly: Prevents JavaScript access (XSS protection)SameSite=Lax: CSRF protectionSecure: Only sent over HTTPS (whenSPARKLYTICS_HTTPS=true)
API Key Authentication
In addition to dashboard authentication, Sparklytics uses API keys for:- Website tracking (public API keys,
POST /api/collect) - Programmatic access (private API keys, analytics queries)
- Self-hosted:
spk_selfhosted_... - Cloud:
spk_live_...
API key management is separate from dashboard authentication. See API Reference for details.
Troubleshooting
”Setup required” Loop
If you’re stuck in a redirect loop:- Check
docker logs sparklyticsfor errors - Verify
SPARKLYTICS_AUTH=localis set - Ensure
/datavolume is writable - Try deleting the DuckDB file and restarting (loses all data)
“Invalid password” on First Login (Password Mode)
- Check that
SPARKLYTICS_PASSWORDis set correctly - Look for trailing spaces or quotes in the env var
- Restart the container after changing env vars
Cookies Not Persisting
- If testing on
http://localhost, setSPARKLYTICS_HTTPS=false - Check browser DevTools → Application → Cookies
- Ensure your browser allows cookies (not in private/incognito mode)
404 on /api/auth/status (None Mode)
This is expected behavior. In none mode, auth endpoints are not registered.
Migration Between Modes
To switch modes:- Backup your data (export events if needed)
- Stop Sparklytics
- Delete the DuckDB file (
./data/sparklytics.db) - Update
SPARKLYTICS_AUTHand related env vars - Restart Sparklytics
- Complete new setup flow (if applicable)
See Also
- Environment Variables — Full configuration reference
- Quick Start — Step-by-step deployment guide
- HTTPS Setup — Secure your deployment