tenseleyflow/shithub / b106c09

Browse files

config: accept email_backend=resend with auth.resend.api_key

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
b106c09ef175d2fe9cae15a93f8b13ced0ec6635
Parents
f171069
Tree
6c1940c

1 changed file

StatusFile+-
M internal/infra/config/config.go 12 3
internal/infra/config/config.gomodified
@@ -181,9 +181,10 @@ type AuthConfig struct {
181181
 	BaseURL                  string         `toml:"base_url"` // e.g. https://shithub.example
182182
 	SiteName                 string         `toml:"site_name"`
183183
 	EmailFrom                string         `toml:"email_from"`
184
-	EmailBackend             string         `toml:"email_backend"` // stdout | smtp | postmark
184
+	EmailBackend             string         `toml:"email_backend"` // stdout | smtp | postmark | resend
185185
 	SMTP                     SMTPConfig     `toml:"smtp"`
186186
 	Postmark                 PostmarkConfig `toml:"postmark"`
187
+	Resend                   ResendConfig   `toml:"resend"`
187188
 	Argon2                   Argon2Config   `toml:"argon2"`
188189
 	TOTPKeyB64               string         `toml:"totp_key_b64"` // base64 32-byte AEAD key for at-rest TOTP secrets
189190
 	SSH                      SSHAuthConfig  `toml:"ssh"`
@@ -207,6 +208,11 @@ type SMTPConfig struct {
207208
 	Password string `toml:"password"`
208209
 }
209210
 
211
+// ResendConfig holds Resend transactional API settings.
212
+type ResendConfig struct {
213
+	APIKey string `toml:"api_key"`
214
+}
215
+
210216
 // PostmarkConfig holds Postmark transactional API settings.
211217
 type PostmarkConfig struct {
212218
 	ServerToken string `toml:"server_token"`
@@ -376,9 +382,9 @@ func Validate(c *Config) error {
376382
 		return err
377383
 	}
378384
 	switch c.Auth.EmailBackend {
379
-	case "stdout", "smtp", "postmark":
385
+	case "stdout", "smtp", "postmark", "resend":
380386
 	default:
381
-		return fmt.Errorf("config: auth.email_backend: must be stdout|smtp|postmark, got %q", c.Auth.EmailBackend)
387
+		return fmt.Errorf("config: auth.email_backend: must be stdout|smtp|postmark|resend, got %q", c.Auth.EmailBackend)
382388
 	}
383389
 	if c.Auth.EmailBackend == "smtp" && c.Auth.SMTP.Addr == "" {
384390
 		return errors.New("config: auth.smtp.addr is required when email_backend=smtp")
@@ -386,6 +392,9 @@ func Validate(c *Config) error {
386392
 	if c.Auth.EmailBackend == "postmark" && c.Auth.Postmark.ServerToken == "" {
387393
 		return errors.New("config: auth.postmark.server_token is required when email_backend=postmark")
388394
 	}
395
+	if c.Auth.EmailBackend == "resend" && c.Auth.Resend.APIKey == "" {
396
+		return errors.New("config: auth.resend.api_key is required when email_backend=resend")
397
+	}
389398
 	if c.Auth.BaseURL == "" {
390399
 		return errors.New("config: auth.base_url is required (used in email links)")
391400
 	}