Skip to content

Open-source AI teammates in Slack, Teams, Discord, Telegram and Mattermost. Self-host it, with any agent harness and any model.

Let the Helm chart read the SMTP username from its Secret

Petr Bauch73d67902195f
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d6723c1d3..ea98eb957 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -68,6 +68,13 @@ version of their own to them without also giving them a release of their own.
stored to never show. `GET /agents/icon-choices` offers none and says why, and
`GET /agents/avatar-settings` tells Switch Console the setting. The default is
unchanged. A server Switch Console runs for you always uses the default.
+- **The Helm chart can take the invitation SMTP username from its Secret.**
+ Some relays issue usernames that are credentials in their own right (an
+ Amazon SES SMTP username is an access key id). With
+ `switchCore.smtp.usernameFromSecret: true`, the chart reads it from
+ `secrets.gatewaySmtpUsername`, or from `GATEWAY_SMTP_USERNAME` in
+ `secrets.existingSecret`, instead of `switchCore.smtp.username`. Setting
+ both is refused at render time.
#### Security
- **An agent icon URL must spell its host plainly.** A link with a backslash,
diff --git a/deploy/remote/helm/switch/templates/_helpers.tpl b/deploy/remote/helm/switch/templates/_helpers.tpl
index 162a2ac1e..a656f4749 100644
--- a/deploy/remote/helm/switch/templates/_helpers.tpl
+++ b/deploy/remote/helm/switch/templates/_helpers.tpl
@@ -78,8 +78,11 @@ MATTERMOST_USER_PASSWORD: {{ .Values.secrets.mattermostUserPassword | default .V
{{- if .Values.switchCore.oidc.enabled }}
GATEWAY_OIDC_CLIENT_SECRET: {{ required "secrets.gatewayOidcClientSecret is required when switchCore.oidc.enabled" .Values.secrets.gatewayOidcClientSecret | b64enc | quote }}
{{- end }}
-{{- if and .Values.switchCore.smtp.enabled .Values.switchCore.smtp.username }}
-GATEWAY_SMTP_PASSWORD: {{ required "secrets.gatewaySmtpPassword is required when switchCore.smtp.username is set" .Values.secrets.gatewaySmtpPassword | b64enc | quote }}
+{{- if and .Values.switchCore.smtp.enabled (or .Values.switchCore.smtp.username .Values.switchCore.smtp.usernameFromSecret) }}
+GATEWAY_SMTP_PASSWORD: {{ required "secrets.gatewaySmtpPassword is required when an SMTP username is set" .Values.secrets.gatewaySmtpPassword | b64enc | quote }}
+{{- end }}
+{{- if and .Values.switchCore.smtp.enabled .Values.switchCore.smtp.usernameFromSecret }}
+GATEWAY_SMTP_USERNAME: {{ required "secrets.gatewaySmtpUsername is required when switchCore.smtp.usernameFromSecret is true" .Values.secrets.gatewaySmtpUsername | b64enc | quote }}
{{- end }}
{{- if .Values.secrets.otlpHeaders }}
OTLP_HEADERS: {{ .Values.secrets.otlpHeaders | b64enc | quote }}
@@ -800,9 +803,19 @@ this one. Drop it once the oldest supported image reads ID_SERVER_NAME. */}}
value: {{ required "switchCore.smtp.from is required when smtp.enabled" .from | quote }}
- name: GATEWAY_INVITE_EMAILS_PER_DAY
value: {{ .emailsPerDayPerWorkspace | quote }}
-{{- if .username }}
+{{- if and .username .usernameFromSecret }}
+{{- fail "switchCore.smtp.username and switchCore.smtp.usernameFromSecret are mutually exclusive: set one." }}
+{{- end }}
+{{- if or .username .usernameFromSecret }}
- name: GATEWAY_SMTP_USERNAME
+{{- if .usernameFromSecret }}
+ valueFrom:
+ secretKeyRef:
+ name: {{ include "switch.secretName" $ }}
+ key: GATEWAY_SMTP_USERNAME
+{{- else }}
value: {{ .username | quote }}
+{{- end }}
- name: GATEWAY_SMTP_PASSWORD
valueFrom:
secretKeyRef:
diff --git a/deploy/remote/helm/switch/values.yaml b/deploy/remote/helm/switch/values.yaml
index 2cc0c00dd..22a37ecf3 100644
--- a/deploy/remote/helm/switch/values.yaml
+++ b/deploy/remote/helm/switch/values.yaml
@@ -139,8 +139,13 @@ secrets:
# Gateway OIDC client secret (required when switchCore.oidc.enabled).
gatewayOidcClientSecret: ""
# SMTP relay password for invitation e-mails (required when
- # switchCore.smtp.enabled and switchCore.smtp.username is set).
+ # switchCore.smtp.enabled and a username is set, either way below).
gatewaySmtpPassword: ""
+ # SMTP relay username, for switchCore.smtp.usernameFromSecret. Some relays
+ # issue usernames that are themselves credentials (an SES SMTP username is
+ # an access key id). With existingSecret, that Secret carries it as
+ # GATEWAY_SMTP_USERNAME instead.
+ gatewaySmtpUsername: ""
# `key=value` pairs, comma-separated, sent on every OTLP request. Here rather
# than beside the other observability settings because the documented use for
# it is a collector's API key, and every other credential in this chart comes
@@ -385,6 +390,11 @@ switchCore:
# Leave empty for a relay that needs no login; set it and
# secrets.gatewaySmtpPassword otherwise.
username: ""
+ # Read the username from the Secret (secrets.gatewaySmtpUsername, or
+ # GATEWAY_SMTP_USERNAME in secrets.existingSecret) rather than from
+ # `username` above, for a relay whose username should not sit in values.
+ # Mutually exclusive with `username`.
+ usernameFromSecret: false
# The From address, e.g. "Switch <invites@your-domain>".
from: ""
# Addressed invitations one workspace may send per 24 hours. With sign-up
diff --git a/docs/old/GATEWAY_OIDC_SETUP.md b/docs/old/GATEWAY_OIDC_SETUP.md
index a46aeca87..90782577c 100644
--- a/docs/old/GATEWAY_OIDC_SETUP.md
+++ b/docs/old/GATEWAY_OIDC_SETUP.md
@@ -180,7 +180,7 @@ interface, Postmark, SendGrid, or your own.
| `GATEWAY_SMTP_HOST` | `switchCore.smtp.host` (and `smtp.enabled: true`) | the relay; setting it turns e-mail on |
| `GATEWAY_SMTP_PORT` | `switchCore.smtp.port` | default 587 |
| `GATEWAY_SMTP_TLS` | `switchCore.smtp.tls` | `starttls` (default, port 587), `tls` (port 465), or `none` for a relay on a trusted network |
-| `GATEWAY_SMTP_USERNAME` / `GATEWAY_SMTP_PASSWORD` | `switchCore.smtp.username` / `secrets.gatewaySmtpPassword` | set both or neither |
+| `GATEWAY_SMTP_USERNAME` / `GATEWAY_SMTP_PASSWORD` | `switchCore.smtp.username` (or `secrets.gatewaySmtpUsername` with `switchCore.smtp.usernameFromSecret: true`) / `secrets.gatewaySmtpPassword` | set both or neither |
| `GATEWAY_SMTP_FROM` | `switchCore.smtp.from` | the From address, e.g. `Switch <invites@your-domain>` |
| `GATEWAY_INVITE_EMAILS_PER_DAY` | `switchCore.smtp.emailsPerDayPerWorkspace` | default 50 |