Email infrastructure + forgot-password reset #5
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The account system needs outbound email — it's the prerequisite for password reset AND for org invites (next issue), and later for delivering keys after purchase.
Email sender — minimal SMTP client (stdlib
net/smtpor a thin wrapper), configured via env:SMTP_HOST,SMTP_PORT,SMTP_USER,SMTP_PASSWORD,MAIL_FROM(e.g.no-reply@swisscairn.ch). All templated mails (reset, invite) share one plain-text template style matching the brand voice.Forgot password
POST /v1/password-reset{email}→ always 204 (no account-existence oracle). If the account exists: mint a single-use token (32B random, 1h expiry, stored server-side), email a linkhttps://www.swisscairn.ch/reset.html?token=….POST /v1/password-reset/confirm{token, newPassword}→ validate token (constant-time, unexpired, unused), set password, burn token, revoke existing sessions.reset.htmlpage.Decision needed at greenlight (Nikola): the SMTP provider + credentials. Infomaniak (already hosting the VPS/domain) offers SMTP with the domain — likely path of least resistance; an API-based sender (e.g. a transactional mail service) is the alternative. Credentials go into
/etc/cairn-license/env, never git.Acceptance: reset flow works end-to-end against the real SMTP (received mail → link → new password → old sessions dead); unknown email indistinguishable from known; expired/reused tokens rejected.
Shipped and deployed (PR #8).
email.go: stdlib SMTP mailer from/etc/cairn-license/env(SMTP_HOST/PORT/USER/PASS/FROM; Infomaniak mailboxno-reply@swisscairn.chconfigured by Nikola, SPF/DKIM/DMARC verified). Implicit TLS on 465, STARTTLS elsewhere; all sends async.POST /v1/password-resetalways 204 (no existence oracle), 1-hour single-use tokens;POST /v1/password-reset/confirmburns the token, sets the password, revokes all sessions. Rate-limited.reset.html.Unit-tested end to end (oracle silence, single use, session revocation, old-password death). Remaining acceptance: one live mail through the real Infomaniak SMTP — pending Nikola's smoke test.