Skip to content

Commit 3c7753b

Browse files
committed
fix(openbao): refuse static-to-shamir migration, mirror the rotation pair check, keep the README table valid
- migrating away from static needs the old stanza with disabled = "true" and its key still mounted, which this chart does not render; refuse the direction regardless of seal.allowMigration instead of emitting a config the migration cannot run against. - fail when seal.previousKeyId is set without seal.previousSecretName, the mirror of the existing check. - drop the shell pipes from the seal.secretName description so the generated parameter table keeps four columns. Assisted-by: LLM Signed-off-by: txmazing <[email protected]>
1 parent 6987101 commit 3c7753b

7 files changed

Lines changed: 57 additions & 7 deletions

File tree

‎api/apps/v1alpha1/openbao/types.go‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/apps/openbao/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ By default OpenBAO uses Shamir key shares: after every pod restart an operator h
2929

3030
To rotate the key, create a second Secret, move the current pair to `previousSecretName`/`previousKeyId` and put the new pair in `secretName`/`keyId`. This is the n-1 rotation the static seal documents: `current_key` is used for new seal operations while `previous_key` still decrypts what was written before. Keep both Secrets in place until OpenBAO has re-wrapped storage with the new key, then drop the `previous*` values and delete the old Secret.
3131

32-
> Switching an existing Shamir-sealed instance to `static` is a seal migration and needs `bao operator unseal -migrate`; see the OpenBAO [seal migration](https://openbao.org/docs/concepts/seal/#seal-migration) documentation. The chart does not run the migration for you. It does refuse to change `seal.type` on an instance that already runs with another seal, because a plain config change would leave a barrier nobody can decrypt. Set `seal.allowMigration: true` only for the upgrade in which you run the migration, then remove it. Migrating away from `static` needs the old stanza kept with `disabled = "true"`, which this chart does not render.
32+
> Switching an existing Shamir-sealed instance to `static` is a seal migration and needs `bao operator unseal -migrate`; see the OpenBAO [seal migration](https://openbao.org/docs/concepts/seal/#seal-migration) documentation. The chart does not run the migration for you. It does refuse to change `seal.type` on an instance that already runs with another seal, because a plain config change would leave a barrier nobody can decrypt. Set `seal.allowMigration: true` only for the upgrade in which you run the migration, then remove it. Migrating away from `static` needs the old stanza kept with `disabled = "true"` and its key still mounted, which this chart does not render; that direction is refused regardless of `allowMigration`.
3333

3434
Keep a copy of the key outside the cluster: a Raft snapshot or a data PVC is unreadable without it.
3535

@@ -62,7 +62,7 @@ Keep a copy of the key outside the cluster: a Raft snapshot or a data PVC is unr
6262
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------- |
6363
| `seal` | Seal configuration. Defaults to Shamir key shares; set `type: static` for auto-unseal. | `object` | `{}` |
6464
| `seal.type` | Seal type. `shamir` keeps the current behaviour; `static` enables auto-unseal from `secretName`. | `string` | `shamir` |
65-
| `seal.secretName` | Existing Secret in the release namespace whose key `key` holds the base64 text of 32 random bytes (`head -c 32 /dev/urandom | base64 | tr -d '\n'`). Required when `type` is `static`. | `string` | `""` |
65+
| `seal.secretName` | Existing Secret in the release namespace whose key `key` holds the base64 text of 32 random bytes (for example `openssl rand -base64 32`). Required when `type` is `static`. | `string` | `""` |
6666
| `seal.keyId` | Permanent identifier of the current key. Change it whenever the key material changes; OpenBAO refuses a key whose identifier it has already seen with different material. Required when `type` is `static`. | `string` | `""` |
6767
| `seal.previousSecretName` | Secret holding the previous key during an n-1 key rotation. | `string` | `""` |
6868
| `seal.previousKeyId` | Identifier of the previous key. Required when `previousSecretName` is set. | `string` | `""` |

‎packages/apps/openbao/templates/openbao.yaml‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
{{- if and $seal.previousSecretName (not $seal.previousKeyId) }}
1010
{{- fail "seal.previousKeyId is required when seal.previousSecretName is set" }}
1111
{{- end }}
12+
{{- if and $seal.previousKeyId (not $seal.previousSecretName) }}
13+
{{- fail "seal.previousSecretName is required when seal.previousKeyId is set" }}
14+
{{- end }}
1215
{{- if and $seal.previousSecretName (not $static) }}
1316
{{- fail "seal.previousSecretName only applies to seal.type \"static\"" }}
1417
{{- end }}
@@ -24,6 +27,14 @@ returns nothing on first install and on dry-run, so the check is a no-op there.
2427
{{- $hcl := index ($cm.data | default dict) "extraconfig-from-values.hcl" | default "" }}
2528
{{- $stanza := regexFind `seal "[a-z]+"` $hcl }}
2629
{{- $liveSeal := ternary (trimAll "\"" (trimPrefix "seal " $stanza)) "shamir" (ne $stanza "") }}
30+
{{- /*
31+
Migrating away from static needs the old stanza kept with disabled = "true"
32+
and its key still mounted, which this chart does not render. Refuse the
33+
direction rather than emit a config the migration cannot run against.
34+
*/}}
35+
{{- if and (eq $liveSeal "static") (eq $seal.type "shamir") }}
36+
{{- fail "migration from seal.type \"static\" to \"shamir\" is not supported by this chart" }}
37+
{{- end }}
2738
{{- if and (ne $liveSeal $seal.type) (not $seal.allowMigration) }}
2839
{{- fail (printf "seal.type %q differs from the seal in use (%q). Changing the seal of an existing instance is a seal migration (bao operator unseal -migrate); set seal.allowMigration: true only while performing it." $seal.type $liveSeal) }}
2940
{{- end }}

‎packages/apps/openbao/tests/seal_test.yaml‎

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,17 @@ tests:
143143
- failedTemplate:
144144
errorMessage: "seal.previousKeyId is required when seal.previousSecretName is set"
145145

146+
- it: "rejects previousKeyId without previousSecretName"
147+
set:
148+
seal:
149+
type: static
150+
secretName: openbao-unseal
151+
keyId: key-2
152+
previousKeyId: key-1
153+
asserts:
154+
- failedTemplate:
155+
errorMessage: "seal.previousSecretName is required when seal.previousKeyId is set"
156+
146157
- it: "rejects previousSecretName with seal.type shamir"
147158
set:
148159
seal:
@@ -214,7 +225,35 @@ tests:
214225
replicas: 3
215226
asserts:
216227
- failedTemplate:
217-
errorPattern: 'seal.type "shamir" differs from the seal in use \("static"\)'
228+
errorMessage: 'migration from seal.type "static" to "shamir" is not supported by this chart'
229+
230+
- it: "refuses static to shamir even with allowMigration: the chart cannot render the disabled legacy stanza"
231+
kubernetesProvider:
232+
scheme:
233+
"v1/ConfigMap":
234+
gvr:
235+
version: "v1"
236+
resource: "configmaps"
237+
namespaced: true
238+
objects:
239+
- kind: ConfigMap
240+
apiVersion: v1
241+
metadata:
242+
name: openbao-test-config
243+
namespace: tenant-test
244+
data:
245+
extraconfig-from-values.hcl: |-
246+
seal "static" {
247+
current_key_id = "key-1"
248+
current_key = "file:///openbao/userconfig/openbao-unseal/key"
249+
}
250+
set:
251+
replicas: 3
252+
seal:
253+
allowMigration: true
254+
asserts:
255+
- failedTemplate:
256+
errorMessage: 'migration from seal.type "static" to "shamir" is not supported by this chart'
218257

219258
- it: "renders when the requested seal matches the seal in use"
220259
kubernetesProvider:

‎packages/apps/openbao/values.schema.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
"default": ""
164164
},
165165
"secretName": {
166-
"description": "Existing Secret in the release namespace whose key `key` holds the base64 text of 32 random bytes (`head -c 32 /dev/urandom | base64 | tr -d '\\n'`). Required when `type` is `static`.",
166+
"description": "Existing Secret in the release namespace whose key `key` holds the base64 text of 32 random bytes (for example `openssl rand -base64 32`). Required when `type` is `static`.",
167167
"type": "string",
168168
"default": ""
169169
},

‎packages/apps/openbao/values.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ ui: true
9292

9393
## @typedef {struct} Seal - Seal configuration. With `static`, the key is read from a Secret you create in the release namespace; the chart never generates or rotates it.
9494
## @field {SealType} type - Seal type. `shamir` keeps the current behaviour; `static` enables auto-unseal from `secretName`.
95-
## @field {string} secretName - Existing Secret in the release namespace whose key `key` holds the base64 text of 32 random bytes (`head -c 32 /dev/urandom | base64 | tr -d '\n'`). Required when `type` is `static`.
95+
## @field {string} secretName - Existing Secret in the release namespace whose key `key` holds the base64 text of 32 random bytes (for example `openssl rand -base64 32`). Required when `type` is `static`.
9696
## @field {string} keyId - Permanent identifier of the current key. Change it whenever the key material changes; OpenBAO refuses a key whose identifier it has already seen with different material. Required when `type` is `static`.
9797
## @field {string} [previousSecretName] - Secret holding the previous key during an n-1 key rotation.
9898
## @field {string} [previousKeyId] - Identifier of the previous key. Required when `previousSecretName` is set.

‎packages/system/openbao-rd/cozyrds/openbao.yaml‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)