feat(identity): register accounts and resend verification mail

This commit is contained in:
shira committed 2026-10-06 23:59:51 +03:00
1 parent 5e202ac972
commit 4436f626a3
55 files changed
+3227 -88

No files matched your search

+23 -2
View File
@@ -120,6 +120,23 @@ type Config struct {
// that may run at once; further logins and registrations wait.
PasswordHashConcurrency int
// IdentityKeySecret keys the HMACs that scope idempotency records and
// rate limit counters by email address, so neither holds a plain hash of
// an address or a password. Empty means a random secret for the life of
// the process.
IdentityKeySecret string
// IdentityAllowEphemeralKey lets a development stand run without
// IDENTITY_KEY_SECRET, with a random secret per process.
IdentityAllowEphemeralKey bool
// VerificationMailMinInterval and VerificationMailDailyLimit bound the
// verification messages to one address: the registration and every
// resend count against both.
VerificationMailMinInterval time.Duration
VerificationMailDailyLimit int
// IdentityClientHourlyLimit bounds the registrations and resends of one
// client network address per hour.
IdentityClientHourlyLimit int
// TrustedProxyCIDRs are the reverse proxies in front of the API. The
// client address is taken from X-Forwarded-For only through them (see
// middleware.ClientIP). Empty trusts no proxy.
@@ -173,6 +190,9 @@ func LoadFromEnv(lookup LookupEnv) (Config, error) {
if err := config.loadPasswordHash(lookup); err != nil {
return Config{}, err
}
if err := config.loadIdentity(lookup); err != nil {
return Config{}, err
}
if err := config.loadTrustedProxies(lookup); err != nil {
return Config{}, err
}
@@ -223,6 +243,9 @@ func (config Config) Validate() error {
if err := config.ValidatePasswordHash(); err != nil {
return err
}
if err := config.ValidateIdentity(); err != nil {
return err
}
if err := validateAddress("HTTP_ADDR", config.HTTPAddr); err != nil {
return err
}
@@ -267,8 +290,6 @@ func DatabaseURLFromEnv(lookup LookupEnv) string {
// boolOrDefault accepts only "true" or "false", ignoring case and surrounding
// spaces. strconv.ParseBool would also accept 1, t, and similar shorthands,
// which are easy to mistype in deployment files.
//
//nolint:unparam // Every setting names its own default; that all current defaults are true is a coincidence.
func boolOrDefault(lookup LookupEnv, key string, fallback bool) (bool, error) {
value, ok := lookup(key)
if !ok {