diff --git a/CHANGELOG.md b/CHANGELOG.md index a45e917..4cdf876 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,7 +42,8 @@ runs, pinned by digest. environment; `webmail.previousAppSecret` reads the old app secret during a rotation. The webmail checks its read-only root at start (`IMMUTABLE`). Every server pod is told both addresses, so it registers them as OAuth - clients. + clients; the webmail's client secret reaches the server as a mounted file + too (`INBUXA_WEBMAIL_CLIENT_SECRET_FILE`), never the environment. - `routes`: the server's, the webmail's and the console's public addresses, each by host name, as Gateway API HTTPRoutes or one Ingress. - `networkPolicy`, on by default: every pod starts from deny all, in and diff --git a/README.md b/README.md index f2adc55..b012396 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,7 @@ capability dropped, no privilege escalation, a read-only root filesystem, the RuntimeDefault seccomp profile. No pod gets a service-account token except the upgrade Job, which scales the server down for a layout change through a Role that only it holds. Secrets reach the pods as mounted files, never as -values. One is still an environment variable until the chart moves to server -27.1-rc.32: the webmail's OAuth client secret, on the server's side. +values or environment variables. NetworkPolicies are on by default (`networkPolicy`) and need a CNI that enforces them. Every pod starts from deny all, in and out: diff --git a/charts/inbuxa/templates/server/deployment.yaml b/charts/inbuxa/templates/server/deployment.yaml index 6b1a3b4..9aa4f37 100644 --- a/charts/inbuxa/templates/server/deployment.yaml +++ b/charts/inbuxa/templates/server/deployment.yaml @@ -22,14 +22,9 @@ metadata: {{- include "inbuxa.labels" $root | nindent 4 }} app.kubernetes.io/component: server inbuxa.org/group: {{ $group }} - {{- with $root.Values.webmail }} - {{- if .enabled }} + {{- if $root.Values.webmail.enabled }} annotations: - ignore-check.kube-linter.io/read-secret-from-env-var: "TODO(K-S2): the webmail's OAuth client secret comes from the environment until the server takes *_FILE" - {{- if .existingSecret }} - ignore-check.kube-linter.io/env-value-from: "webmail.existingSecret is the operator's, made outside the chart" - {{- end }} - {{- end }} + ignore-check.kube-linter.io/env-var-secret: "INBUXA_WEBMAIL_CLIENT_SECRET_FILE holds a path to the mounted secret, not the secret" {{- end }} spec: replicas: {{ $g.replicas }} @@ -149,11 +144,9 @@ spec: {{- if .enabled }} - name: INBUXA_WEBMAIL_URL value: {{ trimSuffix "/" .publicUrl | quote }} - - name: INBUXA_WEBMAIL_CLIENT_SECRET - valueFrom: - secretKeyRef: - name: {{ default (printf "%s-webmail" (include "inbuxa.fullname" $root)) .existingSecret }} - key: oauth-client-secret + # A file, not the environment (K-S2) + - name: INBUXA_WEBMAIL_CLIENT_SECRET_FILE + value: /etc/inbuxa/webmail/oauth-client-secret {{- end }} {{- end }} {{- if $root.Values.console.enabled }} @@ -211,6 +204,11 @@ spec: mountPath: /etc/inbuxa/secrets readOnly: true {{- end }} + {{- if $root.Values.webmail.enabled }} + - name: webmail + mountPath: /etc/inbuxa/webmail + readOnly: true + {{- end }} - name: data mountPath: /var/lib/inbuxa - name: tmp @@ -231,6 +229,18 @@ spec: {{- toYaml .items | nindent 20 }} {{- end }} {{- end }} + {{- with $root.Values.webmail }} + {{- if .enabled }} + # The webmail's OAuth client secret, which the server registers it with + - name: webmail + secret: + secretName: {{ default (printf "%s-webmail" (include "inbuxa.fullname" $root)) .existingSecret }} + defaultMode: 0440 + items: + - key: oauth-client-secret + path: oauth-client-secret + {{- end }} + {{- end }} # Scratch only: everything lasting is in the data store - name: data emptyDir: {} diff --git a/charts/inbuxa/tests/frontends_test.yaml b/charts/inbuxa/tests/frontends_test.yaml index 245bab7..4d85784 100644 --- a/charts/inbuxa/tests/frontends_test.yaml +++ b/charts/inbuxa/tests/frontends_test.yaml @@ -137,11 +137,25 @@ tests: - contains: path: spec.template.spec.containers[0].env content: {name: INBUXA_WEBMAIL_URL, value: "https://webmail.example.org"} + # From a file, never the environment - contains: path: spec.template.spec.containers[0].env + content: {name: INBUXA_WEBMAIL_CLIENT_SECRET_FILE, value: /etc/inbuxa/webmail/oauth-client-secret} + - notContains: + path: spec.template.spec.containers[0].env + content: {name: INBUXA_WEBMAIL_CLIENT_SECRET} + any: true + - contains: + path: spec.template.spec.volumes content: - name: INBUXA_WEBMAIL_CLIENT_SECRET - valueFrom: {secretKeyRef: {name: mail-inbuxa-webmail, key: oauth-client-secret}} + name: webmail + secret: + secretName: mail-inbuxa-webmail + defaultMode: 0440 + items: [{key: oauth-client-secret, path: oauth-client-secret}] + - contains: + path: spec.template.spec.containers[0].volumeMounts + content: {name: webmail, mountPath: /etc/inbuxa/webmail, readOnly: true} - contains: path: spec.template.spec.containers[0].env content: {name: INBUXA_ADMIN_URL, value: "https://admin.example.org"}