The lines under "Doc and comment drift" that the findings' own commits did not already fix: - security.md: a newer confirmation link replaces the older, a reset link is not replaced; html/template renders every page (no themes); the container keeps eight capabilities, named, not "KILL". - architecture.md: ImportKey writes over a name's key, as an import must; the error text reaches the browser on the Backup page's import refusal. - guide: with Caddy the key is in Caddy's data, so a full backup refuses until certs/ holds a copy (or back up caddy-data). - comments: sasldb2 holds application passwords in the clear (store, app/password.go); texthash folds ASCII (sender.go); the supervisor socket's group is supervisor (rpc.go); cert-reload's OpenSSL measurement was 3.0.x of bookworm; sendReset's limits (links.go). Migration 0013's comment stays as shipped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
1.0 KiB
Go
29 lines
1.0 KiB
Go
package app
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"encoding/base64"
|
|
"fmt"
|
|
)
|
|
|
|
// passwordBytes is the number of random bytes behind a generated application
|
|
// password. 24 bytes = 192 bits of entropy, well above any brute-force concern
|
|
// for a SASL credential the panel shows exactly once (security.md).
|
|
const passwordBytes = 24
|
|
|
|
// generatePassword returns a strong, URL-safe random password for an
|
|
// application's SASL account. The panel generates it, shows it once and never
|
|
// stores it in its own database; sasldb2 keeps it, in the clear, as Cyrus
|
|
// does for PLAIN and LOGIN (security.md).
|
|
//
|
|
// base64url output keeps the password to a safe ASCII alphabet with no shell or
|
|
// SMTP-special characters, so it survives being typed into client configuration
|
|
// and passed to saslpasswd2 over stdin unchanged.
|
|
func generatePassword() (string, error) {
|
|
buf := make([]byte, passwordBytes)
|
|
if _, err := rand.Read(buf); err != nil {
|
|
return "", fmt.Errorf("generate password: %w", err)
|
|
}
|
|
return base64.RawURLEncoding.EncodeToString(buf), nil
|
|
}
|