mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-05 14:42:05 +09:00
feat(clickhouse)!: render a CredentialTemplate per user
Tenant passwords move to platform-minted credentials. The chart no longer generates, looks up or renders any tenant password and ignores users.<name>.password: it renders one CredentialTemplate per user, and cozystack-controller keeps the account Secret holding the SHA-256 of the password the Cozystack API mints. The operator watches no Secrets, and a hash inline in the ClickHouseInstallation is the only path it applies without a restart, so the template asks for a valuesPath: the HelmRelease pulls each stored hash into _accounts.u<digest of the user name>, the chart renders it as password_sha256_hex, and the Flux watch label upgrades the release when a mint changes the Secret. A user with no verifier in the values is left out of the installation, because the operator would give a passwordless user the password "default". backup stays a platform account in <release>-credentials, which now holds only it, is labelled not tenant visible and is no longer selected by the ApplicationDefinition. The names backup, default and clickhouse_operator are refused for tenant users. A rotation of the backup password restarts the pods once, since the backup sidecar reads it from its environment at start. A user whose account name is longer than 63 characters, does not start and end with a letter or a digit, or is shared with another user is refused at render, as credentials-migrate refuses it, so an install and an upgrade accept the same names. A users.<name>.password left in values draws an admission warning that points at a mint on the user's Credential. Existing clients lose readable passwords; an administrator mints a new one. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
This commit is contained in:
14 files changed
+399
-53
No files matched your search
@@ -2365,8 +2365,9 @@ func (r *REST) warnRemovedKubernetesFields(ctx context.Context, app *appsv1alpha
|
||||
// change it. Warn so an operator editing it is told it has no effect instead of
|
||||
// getting a silent 200, and where the password comes from now.
|
||||
var removedUserPasswordKinds = map[string]string{
|
||||
postgresKind: mintedPasswordWarning,
|
||||
mariadbKind: "spec.users[%q].password is ignored: passwords are auto-generated into the <release>-credentials Secret and cannot be set from values. Read the current password from that Secret; editing this field has no effect.",
|
||||
postgresKind: mintedPasswordWarning,
|
||||
mariadbKind: "spec.users[%q].password is ignored: passwords are auto-generated into the <release>-credentials Secret and cannot be set from values. Read the current password from that Secret; editing this field has no effect.",
|
||||
clickhouseKind: mintedPasswordWarning,
|
||||
}
|
||||
|
||||
// mintedPasswordWarning is the warning of a kind whose user passwords the
|
||||
@@ -2375,8 +2376,9 @@ var removedUserPasswordKinds = map[string]string{
|
||||
const mintedPasswordWarning = "spec.users[%q].password is ignored: passwords are issued through the credentials API and cannot be set from values. Mint a new password on the user's Credential (credentials.core.cozystack.io, mint subresource); editing this field has no effect."
|
||||
|
||||
const (
|
||||
postgresKind = "Postgres"
|
||||
mariadbKind = "MariaDB"
|
||||
clickhouseKind = "ClickHouse"
|
||||
postgresKind = "Postgres"
|
||||
mariadbKind = "MariaDB"
|
||||
)
|
||||
|
||||
// warnRemovedUserPasswords emits a client-facing admission warning for every
|
||||
|
||||
@@ -164,6 +164,7 @@ func TestWarnRemovedUserPasswords(t *testing.T) {
|
||||
}{
|
||||
{"postgres warns", postgresKind, rawWithPassword, true},
|
||||
{"mariadb warns", mariadbKind, rawWithPassword, true},
|
||||
{"clickhouse warns", clickhouseKind, rawWithPassword, true},
|
||||
{"other kind stays quiet", "Redis", rawWithPassword, false},
|
||||
{"no password stays quiet", postgresKind, `{"users":{"app":{}}}`, false},
|
||||
{"warns on a good user despite a non-object user", postgresKind, `{"users":{"good":{"password":"x"},"bad":"str"}}`, true},
|
||||
@@ -195,7 +196,7 @@ func TestWarnRemovedUserPasswords(t *testing.T) {
|
||||
// mint on the user's Credential: its <release>-credentials Secret holds no user
|
||||
// password a tenant can read, so naming it sends the reader to a dead end.
|
||||
func TestWarnRemovedUserPasswords_PointsAtMint(t *testing.T) {
|
||||
for _, kind := range []string{postgresKind} {
|
||||
for _, kind := range []string{postgresKind, clickhouseKind} {
|
||||
t.Run(kind, func(t *testing.T) {
|
||||
r := &REST{kindName: kind}
|
||||
app := &appsv1alpha1.Application{Spec: &apiextv1.JSON{Raw: []byte(`{"users":{"app":{"password":"hackme"}}}`)}}
|
||||
|
||||
Reference in new issue
Block a user