Skip to content

Commit dbdeb07

Browse files
dannykoppingpull[bot]
authored andcommitted
feat: add SMTP auth & TLS support (#13902)
1 parent eeee60e commit dbdeb07

File tree

29 files changed

+1949
-117
lines changed

29 files changed

+1949
-117
lines changed

.github/workflows/typos.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ hel = "hel"
2020
pn = "pn"
2121
# typos doesn't like the EDE in TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA
2222
EDE = "EDE"
23+
# HELO is an SMTP command
24+
HELO = "HELO"
2325

2426
[files]
2527
extend-exclude = [

cli/testdata/coder_server_--help.golden

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,8 @@ can safely ignore these settings.
327327
"tls11", "tls12" or "tls13".
328328

329329
NOTIFICATIONS OPTIONS:
330+
Configure how notifications are processed and delivered.
331+
330332
--notifications-dispatch-timeout duration, $CODER_NOTIFICATIONS_DISPATCH_TIMEOUT (default: 1m0s)
331333
How long to wait while a notification is being sent before giving up.
332334

@@ -337,6 +339,11 @@ NOTIFICATIONS OPTIONS:
337339
Which delivery method to use (available options: 'smtp', 'webhook').
338340

339341
NOTIFICATIONS / EMAIL OPTIONS:
342+
Configure how email notifications are sent.
343+
344+
--notifications-email-force-tls bool, $CODER_NOTIFICATIONS_EMAIL_FORCE_TLS (default: false)
345+
Force a TLS connection to the configured SMTP smarthost.
346+
340347
--notifications-email-from string, $CODER_NOTIFICATIONS_EMAIL_FROM
341348
The sender's address to use.
342349

@@ -346,6 +353,43 @@ NOTIFICATIONS / EMAIL OPTIONS:
346353
--notifications-email-smarthost host:port, $CODER_NOTIFICATIONS_EMAIL_SMARTHOST (default: localhost:587)
347354
The intermediary SMTP host through which emails are sent.
348355

356+
NOTIFICATIONS / EMAIL / EMAIL AUTHENTICATION OPTIONS:
357+
Configure SMTP authentication options.
358+
359+
--notifications-email-auth-identity string, $CODER_NOTIFICATIONS_EMAIL_AUTH_IDENTITY
360+
Identity to use with PLAIN authentication.
361+
362+
--notifications-email-auth-password string, $CODER_NOTIFICATIONS_EMAIL_AUTH_PASSWORD
363+
Password to use with PLAIN/LOGIN authentication.
364+
365+
--notifications-email-auth-password-file string, $CODER_NOTIFICATIONS_EMAIL_AUTH_PASSWORD_FILE
366+
File from which to load password for use with PLAIN/LOGIN
367+
authentication.
368+
369+
--notifications-email-auth-username string, $CODER_NOTIFICATIONS_EMAIL_AUTH_USERNAME
370+
Username to use with PLAIN/LOGIN authentication.
371+
372+
NOTIFICATIONS / EMAIL / EMAIL TLS OPTIONS:
373+
Configure TLS for your SMTP server target.
374+
375+
--notifications-email-tls-ca-cert-file string, $CODER_NOTIFICATIONS_EMAIL_TLS_CACERTFILE
376+
CA certificate file to use.
377+
378+
--notifications-email-tls-cert-file string, $CODER_NOTIFICATIONS_EMAIL_TLS_CERTFILE
379+
Certificate file to use.
380+
381+
--notifications-email-tls-cert-key-file string, $CODER_NOTIFICATIONS_EMAIL_TLS_CERTKEYFILE
382+
Certificate key file to use.
383+
384+
--notifications-email-tls-server-name string, $CODER_NOTIFICATIONS_EMAIL_TLS_SERVERNAME
385+
Server name to verify against the target certificate.
386+
387+
--notifications-email-tls-skip-verify bool, $CODER_NOTIFICATIONS_EMAIL_TLS_SKIPVERIFY
388+
Skip verification of the target server's certificate (insecure).
389+
390+
--notifications-email-tls-starttls bool, $CODER_NOTIFICATIONS_EMAIL_TLS_STARTTLS
391+
Enable STARTTLS to upgrade insecure SMTP connections using TLS.
392+
349393
NOTIFICATIONS / WEBHOOK OPTIONS:
350394
--notifications-webhook-endpoint url, $CODER_NOTIFICATIONS_WEBHOOK_ENDPOINT
351395
The endpoint to which to send webhooks.

cli/testdata/server-config.yaml.golden

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -493,13 +493,15 @@ userQuietHoursSchedule:
493493
# compatibility reasons, this will be removed in a future release.
494494
# (default: false, type: bool)
495495
allowWorkspaceRenames: false
496+
# Configure how notifications are processed and delivered.
496497
notifications:
497498
# Which delivery method to use (available options: 'smtp', 'webhook').
498499
# (default: smtp, type: string)
499500
method: smtp
500501
# How long to wait while a notification is being sent before giving up.
501502
# (default: 1m0s, type: duration)
502-
dispatch-timeout: 1m0s
503+
dispatchTimeout: 1m0s
504+
# Configure how email notifications are sent.
503505
email:
504506
# The sender's address to use.
505507
# (default: <unset>, type: string)
@@ -510,41 +512,78 @@ notifications:
510512
# The hostname identifying the SMTP server.
511513
# (default: localhost, type: string)
512514
hello: localhost
515+
# Force a TLS connection to the configured SMTP smarthost.
516+
# (default: false, type: bool)
517+
forceTLS: false
518+
# Configure SMTP authentication options.
519+
emailAuth:
520+
# Identity to use with PLAIN authentication.
521+
# (default: <unset>, type: string)
522+
identity: ""
523+
# Username to use with PLAIN/LOGIN authentication.
524+
# (default: <unset>, type: string)
525+
username: ""
526+
# Password to use with PLAIN/LOGIN authentication.
527+
# (default: <unset>, type: string)
528+
password: ""
529+
# File from which to load password for use with PLAIN/LOGIN authentication.
530+
# (default: <unset>, type: string)
531+
passwordFile: ""
532+
# Configure TLS for your SMTP server target.
533+
emailTLS:
534+
# Enable STARTTLS to upgrade insecure SMTP connections using TLS.
535+
# (default: <unset>, type: bool)
536+
startTLS: false
537+
# Server name to verify against the target certificate.
538+
# (default: <unset>, type: string)
539+
serverName: ""
540+
# Skip verification of the target server's certificate (insecure).
541+
# (default: <unset>, type: bool)
542+
insecureSkipVerify: false
543+
# CA certificate file to use.
544+
# (default: <unset>, type: string)
545+
caCertFile: ""
546+
# Certificate file to use.
547+
# (default: <unset>, type: string)
548+
certFile: ""
549+
# Certificate key file to use.
550+
# (default: <unset>, type: string)
551+
certKeyFile: ""
513552
webhook:
514553
# The endpoint to which to send webhooks.
515554
# (default: <unset>, type: url)
516555
hello:
517556
# The upper limit of attempts to send a notification.
518557
# (default: 5, type: int)
519-
max-send-attempts: 5
558+
maxSendAttempts: 5
520559
# The minimum time between retries.
521560
# (default: 5m0s, type: duration)
522-
retry-interval: 5m0s
561+
retryInterval: 5m0s
523562
# The notifications system buffers message updates in memory to ease pressure on
524563
# the database. This option controls how often it synchronizes its state with the
525564
# database. The shorter this value the lower the change of state inconsistency in
526565
# a non-graceful shutdown - but it also increases load on the database. It is
527566
# recommended to keep this option at its default value.
528567
# (default: 2s, type: duration)
529-
store-sync-interval: 2s
568+
storeSyncInterval: 2s
530569
# The notifications system buffers message updates in memory to ease pressure on
531570
# the database. This option controls how many updates are kept in memory. The
532571
# lower this value the lower the change of state inconsistency in a non-graceful
533572
# shutdown - but it also increases load on the database. It is recommended to keep
534573
# this option at its default value.
535574
# (default: 50, type: int)
536-
store-sync-buffer-size: 50
575+
storeSyncBufferSize: 50
537576
# How long a notifier should lease a message. This is effectively how long a
538577
# notification is 'owned' by a notifier, and once this period expires it will be
539578
# available for lease by another notifier. Leasing is important in order for
540579
# multiple running notifiers to not pick the same messages to deliver
541580
# concurrently. This lease period will only expire if a notifier shuts down
542581
# ungracefully; a dispatch of the notification releases the lease.
543582
# (default: 2m0s, type: duration)
544-
lease-period: 2m0s
583+
leasePeriod: 2m0s
545584
# How many notifications a notifier should lease per fetch interval.
546585
# (default: 20, type: int)
547-
lease-count: 20
586+
leaseCount: 20
548587
# How often to query the database for queued notifications.
549588
# (default: 15s, type: duration)
550-
fetch-interval: 15s
589+
fetchInterval: 15s

coderd/apidoc/docs.go

Lines changed: 70 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 70 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[ req ]
2+
distinguished_name = req_distinguished_name
3+
x509_extensions = v3_ca
4+
prompt = no
5+
6+
[ req_distinguished_name ]
7+
C = ZA
8+
ST = WC
9+
L = Cape Town
10+
O = Coder
11+
OU = Team Coconut
12+
CN = Coder CA
13+
14+
[ v3_ca ]
15+
basicConstraints = critical,CA:TRUE
16+
keyUsage = critical,keyCertSign,cRLSign
17+
subjectKeyIdentifier = hash
18+
authorityKeyIdentifier = keyid:always,issuer:always
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIIESjCCAzKgAwIBAgIUceUne8C8ezg1leBzhm5M5QLjBc4wDQYJKoZIhvcNAQEL
3+
BQAwaDELMAkGA1UEBhMCWkExCzAJBgNVBAgMAldDMRIwEAYDVQQHDAlDYXBlIFRv
4+
d24xDjAMBgNVBAoMBUNvZGVyMRUwEwYDVQQLDAxUZWFtIENvY29udXQxETAPBgNV
5+
BAMMCENvZGVyIENBMB4XDTI0MDcxNTEzMzYwOFoXDTM0MDcxMzEzMzYwOFowaDEL
6+
MAkGA1UEBhMCWkExCzAJBgNVBAgMAldDMRIwEAYDVQQHDAlDYXBlIFRvd24xDjAM
7+
BgNVBAoMBUNvZGVyMRUwEwYDVQQLDAxUZWFtIENvY29udXQxETAPBgNVBAMMCENv
8+
ZGVyIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAijVhQfmImkQF
9+
kDiBqCdSAaG7dO7slAjJH0jYizYCwVzCKP72Z7DJ2b/ohcGBw1YWZ8dOm88uCpsS
10+
oWM5FvxIeaNeGpcFar+wEoR/o5p91DgwvpmkbNyu3uQaNRvIKoqGdTAu5GUNd+Ej
11+
MxvwfofgRetziA56sa6ovQV11hPbKxp0YbSJXMRN64sGCqx+VNqpk2A57JCdCjcB
12+
T1fc7LIqKc9uoqCaC0Hr2OaBCc8IxLwpwwOz5qCaOGmylXY3YE4lKNJkA1s/HXO/
13+
GAZ6aO0GqkO00fxIQwW13BexuaiDJfcAhUmJ8CjFt9qgKfnkP26jU8gfMxOkRkn2
14+
qG8sWy3z8wIDAQABo4HrMIHoMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQD
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