Repository navigation
Conversation
Both ACL loaders ignored the error from user.NewPassword, so an unusable operator secret produced a nil password: - the startup helper turned it into "nopass" in the ACL file, leaving the operator account open on every pod that restarted; - the operator-side loader kept the user without its secret name, and writing it back to the ACL ConfigMap would lead to the same "nopass" at the next pod start. The password-sha256 support adds a new way to hit this (a secret with both password and password-sha256), so the operator user now fails loudly instead: a missing or empty password, both keys, or a hash is an error. The operator authenticates with this account, so it needs a non-empty plaintext. The new user.ValidateOperatorPassword holds that rule for both loaders. Other users keep their behaviour: an unusable secret leaves the user out of the ACL file, so it can not log in. That is not an error, because the helper runs at every pod start and one bad custom secret must not keep the whole instance from starting. The helper logic moves into loadUserPassword so it can be unit tested. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The operator authenticates with the system account, so it needs the plaintext password. The webhook returned early for system accounts and accepted a password-sha256 secret; the User was then only rejected later by the controller. Check the secrets at admission instead, so the mistake fails at once with a clear message. A system-account secret that does not exist yet is still accepted, as before, and left to the controller. Also adds webhook tests for password-sha256 secrets: a hash on a custom account skips the plaintext check, and a malformed hash or a secret with both keys is rejected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Explain how to keep only the SHA-256 of a password in a User secret: how to create it without the password ever being shown or saved, why printf '%s' rather than echo, the one-key-only rule, and how to move an existing secret such as the default user's with a patch instead of recreating it, which would drop the operator's finalizer and owner reference. State the limits: the operator's own system account and the sentinel password still need the plaintext, because the operator logs in with them. Warn that password strength can not be checked from a hash, and that SHA-256 is fast and unsalted, so a weak password can be recovered by anyone who can read the secret. Choosing a strong password stays with whoever creates it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I reviewed #168 · The reported #167 · A valid hash works for an application user with one Secret. The controller sends
All 41 packages with tests passed locally. The PR’s system test covered restart and rotation on a single TLS-enabled |
Operator user (chideat#168): check the operator's final password in both ACL loaders, not only when its entry references a secret. An older ACL configmap whose operator entry lost the secret reference now fails ACL generation instead of being applied as "nopass". Default user: a configured default user with an unusable secret fails ACL generation instead of being skipped, since Valkey recreates its built-in default user without a password when the ACL file leaves it out. A weak plaintext default password is still applied: its strength is checked on admission, and dropping it would leave no password. Reserve the operator username for the system account in the webhook, the reconciler and the handler: the live ACL update and the ACL configmap select an account by username, so a custom User named operator would replace the operator's credentials. Sentinel: reject a hash-only or empty defaultPasswordSecret in NewSentinelUser, and make the startup script refuse to start when the mounted secret has password-sha256 or no password, since requirepass has no hashed form. Keep every spec.passwordSecrets reference in the ACL configmap through a new additionalPasswords field, and apply all of them on restart, so a password rotation with two secrets survives a pod restart. Check that a secret sets exactly one of password and password-sha256 by key presence: a hash with an empty password key is now rejected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for the comment @chideat . #168: operator user
#167: review points
Decisions you may want to weigh in on
Testing
I ran the system tests with an image built from eb8d0a5, on Kubernetes v1.36.4 with Valkey 9.1.2. Regression, Review follow-ups on the same instance:
Sentinel failover, as you suggested. I used a temporary
Sentinel password, on a 2-pod run of the same setup:
Found while testing (not caused by this PR, I think)When a Secret is removed from a User's
|
Closes #167
Fixes #168
What
A
User's password Secret can now holdpassword-sha256, the hex SHA-256 of the password, instead ofpassword. Only the hash is ever stored in the cluster:password-sha256Secret is checked for a well-formed digest (64 hex characters), not for the plaintext rules. A Secret that sets both keys is rejected.#<hash>instead of>passwordwithACL SETUSERon every node.#<hash>into the ACL file, so the user survives restarts and failovers.Changing the password still works by updating the Secret. Plaintext Secrets work exactly as before.
Why
Valkey checks passwords against their SHA-256, so it doesn't need the plaintext. For application accounts, keeping the plaintext in the cluster is avoidable exposure. See #167.
Safety changes in the same PR
passwordandpassword-sha256. This is checked by which keys are present, so a hash next to an emptypasswordkey is rejected.systemaccount can't use a hash. The operator logs in with it, sopassword-sha256on asystemaccount is rejected by the webhook and by the controller.nopassfor a User. A Secret that gives no password now fails theUser, which goes toFailwith a message and is retried. Nothing is applied to the nodes.nopassfor theoperatoruser (The operator user gets nopass when its password Secret has no usable password #168). An unusableoperatorSecret is now an error, in both the startup helper and the operator, instead of a discarded error that becomesnopass. Both also check the operator's final password, so an entry that lost its Secret reference fails instead of becomingnopass.nopassfor a configureddefaultuser. An unusabledefaultSecret fails ACL generation. Skipping the user would let Valkey recreate the built-indefaultuser with no password.operatoris a reserved username. The webhook, the reconciler and the handler reject a custom User namedoperator, which would otherwise replace the operator's credentials.requirepasshas no hashed form, so a hash-only or emptydefaultPasswordSecretis rejected by the operator, andrun_sentinel.shrefuses to start with it.passwordSecretsentry survives a restart. The ACL ConfigMap keeps all references in a newadditionalPasswordsfield, so a rotation with two Secrets keeps working across pod restarts. Older helper images ignore the field.Limits
systemaccount and the sentinel password (spec.sentinel.access.defaultPasswordSecret) still need the plaintext, because the operator logs in with them. The Cluster and Failoverdefaultuser is a regularUser, so it can use a hash.Testing
make testpasses.ACLRule(pkg/types/user);loadUserPassword(cmd/helper/commands/helper);password-sha256(internal/webhook/v1alpha1);Userhandler (internal/controller/user).replica(1 node, TLS). All 40 checks passed:password-sha256, and the ACL ConfigMap holds only the Secret name.#<hash>(no>rule) into the ACL file, and logins still work.systemaccount, and accepts a valid hash on a custom account.Fail, while the node keeps the previous hash and is nevernopass.operatorSecret (password missing, or both keys set): the helper fails,run_failover.shexits, and Valkey never starts with that ACL. Nonopassoperator account is reachable. Once the Secret is fixed, the pod comes back with the password.operatoris rejected. TwopasswordSecretsboth work, also after a restart, and a rotation works. A configureddefaultuser with a broken Secret stops the pod instead of starting with no password. Anoperatorentry without a Secret reference stops the pod instead of starting asnopass.defaultPasswordSecretstops the sentinel from starting.Commits
feat(user): the feature itself, across the webhook, operator, helper and controller.fix(acl): nonopassfor theoperatoruser (The operator user gets nopass when its password Secret has no usable password #168).fix(webhook):password-sha256rejected onsystemaccounts at admission.docs: user guide and API reference.fix(acl): review follow-ups (default user, reservedoperatorusername, sentinel password,additionalPasswords, key-presence check).Docs
docs/guides/user-guide.md: new section, "Storing only a hash of the password".docs/api/v1alpha1-user.md: describes thepassword-sha256key.🤖 Generated with Claude Code