Add CLI flags for setup and server configuration

- Add --setup flag to create admin user
- Add --admin-user and --admin-password for setup
- Generate cryptographically random passwords for --setup
- Add --bind and --port flags for server binding
- Add BIND env var support
- Add SMTP email service for password reset
- Add password reset token storage
- Add auth header to queue/logs frontend pages
- Fix journalctl timestamp format
- Fix logs to return empty array instead of error when no entries
- Fix queue handler to return proper error message
- Hide Users/Aliases nav links when no domain selected
This commit is contained in:
Christoph Haas 2026-03-22 01:17:43 +01:00
parent 2c3a4c3daa
commit 53ce3b06ae
14 changed files with 435 additions and 69 deletions

View file

@ -12,6 +12,7 @@ type Config struct {
DBUser string
DBPassword string
DBName string
Bind string
Port string
UseEmbedded bool
JWTSecret string
@ -23,6 +24,12 @@ type Config struct {
DovecotQuotaCmd string
JournalctlPath string
RspamdAPI string
SMTPHost string
SMTPPort string
SMTPUser string
SMTPPassword string
SMTPFrom string
BaseURL string
}
func Load() *Config {
@ -34,9 +41,10 @@ func Load() *Config {
DBUser: getEnv("DB_USER", "mailadmin"),
DBPassword: getEnv("DB_PASSWORD", ""),
DBName: getEnv("DB_NAME", "mailserver"),
Bind: getEnv("BIND", "0.0.0.0"),
Port: getEnv("PORT", "8080"),
UseEmbedded: getEnv("USE_EMBEDDED", "true") == "true",
JWTSecret: getEnv("JWT_SECRET", "change-this-secret"),
JWTSecret: getEnv("JWT_SECRET", "change-this-secret-in-production"),
AdminUser: getEnv("ADMIN_USER", ""),
AdminPassword: getEnv("ADMIN_PASSWORD", ""),
MailDataDir: getEnv("MAIL_DATA_DIR", "/var/vmail"),
@ -45,6 +53,12 @@ func Load() *Config {
DovecotQuotaCmd: getEnv("DOVECOT_QUOTA_CMD", "/usr/bin/doveadm"),
JournalctlPath: getEnv("JOURNALCTL_PATH", "/usr/bin/journalctl"),
RspamdAPI: getEnv("RSPAMD_API", "http://127.0.0.1:11334"),
SMTPHost: getEnv("SMTP_HOST", "localhost"),
SMTPPort: getEnv("SMTP_PORT", "587"),
SMTPUser: getEnv("SMTP_USER", ""),
SMTPPassword: getEnv("SMTP_PASSWORD", ""),
SMTPFrom: getEnv("SMTP_FROM", "noreply@localhost"),
BaseURL: getEnv("BASE_URL", "http://localhost:8080"),
}
}