mirror of
https://github.com/cozystack/cozystack.git
synced 2026-12-06 07:03:45 +09:00
feat(rabbitmq)!: render a CredentialTemplate per user
RabbitMQ passwords were generated at render time, kept with lookup and stored in a per-user Secret that every tenant tier could read, next to the operator's administrator in -default-user. The chart now renders a CredentialTemplate per user and points each User's importCredentialsSecret at the account Secret the credentials API mints into. messaging-topology-operator 1.20.2 watches that Secret and puts the password to the broker again on every change, so a mint applies without a Helm run. The operator hashes the password itself, so the account Secret holds the plaintext, as the design's wave 2 does; no tenant role reads it. The User objects keep their names, since a rename would make the operator delete and recreate the broker user. -default-user is a platform account: the ApplicationDefinition stops selecting it and excludes it instead. Tenants lose the administrator login and the per-user Secrets; users.<name>.password is no longer read, and a value left there draws an admission warning that points at a mint on the user's Credential. 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. Assisted-by: LLM Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
This commit is contained in:
13 files changed
+225
-88
No files matched your search
Generated
+1
-3
@@ -46,7 +46,7 @@ type ConfigSpec struct {
|
||||
// RabbitMQ major.minor version to deploy
|
||||
// +kubebuilder:default:="v4.2"
|
||||
Version Version `json:"version"`
|
||||
// Users configuration map.
|
||||
// Users configuration map. Each user is a RabbitMQ user that messaging-topology-operator keeps from an account Secret the platform holds. Passwords are issued through the Cozystack credentials API: a mint on the account's `Credential` (`core.cozystack.io`) returns a new password once, and a revoke retires the password without issuing one. The operator applies either to the broker within seconds. A `password` key here is ignored. The administrator in `<release>-default-user` belongs to the platform and is not shown to tenants.
|
||||
// +kubebuilder:default:={}
|
||||
Users map[string]User `json:"users,omitempty"`
|
||||
// Virtual hosts configuration map.
|
||||
@@ -80,8 +80,6 @@ type TLS struct {
|
||||
}
|
||||
|
||||
type User struct {
|
||||
// Password for the user.
|
||||
Password string `json:"password,omitempty"`
|
||||
}
|
||||
|
||||
type Vhost struct {
|
||||
|
||||
@@ -34,12 +34,16 @@ COZYRDS="$REPO_ROOT/packages/system/rabbitmq-rd/cozyrds/rabbitmq.yaml"
|
||||
# label whitelist alone passes an added name. Either dimension reaches a
|
||||
# key-bearing Secret -- controller.cert-manager.io/fao is stamped on both the CA
|
||||
# and the leaf, so a selector on it is a one-line grant of the CA private key.
|
||||
EXPECTED_RD_INCLUDE='[{"resourceNames":["rabbitmq-{{ .name }}-default-user"]},{"matchLabels":{"internal.cozystack.io/tenant-ca":"true"}},{"matchLabels":{"apps.cozystack.io/user-secret":"true"}}]'
|
||||
#
|
||||
# Since the credentials conversion the trust anchor is the only Secret a tenant
|
||||
# reads here: -default-user is the platform administrator, and the tenant
|
||||
# accounts live in account Secrets no definition selects.
|
||||
EXPECTED_RD_INCLUDE='[{"matchLabels":{"internal.cozystack.io/tenant-ca":"true"}}]'
|
||||
|
||||
# exclude is evaluated before include and wins, so it is the structural backstop
|
||||
# against a mis-stamped label on a key-bearing object. Asserted whole for the same
|
||||
# reason as the include: dropping one entry is the edit that has to be caught.
|
||||
EXPECTED_RD_EXCLUDE='[{"resourceNames":["rabbitmq-{{ .name }}-ca","rabbitmq-{{ .name }}-tls","rabbitmq-{{ .name }}-erlang-cookie"]}]'
|
||||
EXPECTED_RD_EXCLUDE='[{"resourceNames":["rabbitmq-{{ .name }}-ca","rabbitmq-{{ .name }}-tls","rabbitmq-{{ .name }}-erlang-cookie","rabbitmq-{{ .name }}-default-user"]}]'
|
||||
|
||||
# Subsumed by the whitelist below, which cannot match without this entry. Kept
|
||||
# because the runner stops at the first failing test, so this one fires first and
|
||||
@@ -61,7 +65,7 @@ EXPECTED_RD_EXCLUDE='[{"resourceNames":["rabbitmq-{{ .name }}-ca","rabbitmq-{{ .
|
||||
fi
|
||||
}
|
||||
|
||||
@test "rabbitmq-rd cozyrds grants nothing beyond the default user, the trust anchor and user credentials" {
|
||||
@test "rabbitmq-rd cozyrds grants nothing beyond the trust anchor" {
|
||||
if [ ! -f "$COZYRDS" ]; then
|
||||
echo "ResourceDefinition not found at $COZYRDS -- did it move?" >&2
|
||||
exit 1
|
||||
|
||||
@@ -40,15 +40,14 @@ The scope is **definitions only** — vhosts, users, permissions, queues, exchan
|
||||
|
||||
### Application-specific parameters
|
||||
|
||||
| Name | Description | Type | Value |
|
||||
| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | ----- |
|
||||
| `users` | Users configuration map. | `map[string]object` | `{}` |
|
||||
| `users[name].password` | Password for the user. | `string` | `""` |
|
||||
| `vhosts` | Virtual hosts configuration map. | `map[string]object` | `{}` |
|
||||
| `vhosts[name].roles` | Virtual host roles list. | `object` | `{}` |
|
||||
| `vhosts[name].roles.admin` | List of admin users. | `[]string` | `[]` |
|
||||
| `vhosts[name].roles.readonly` | List of readonly users. | `[]string` | `[]` |
|
||||
| `schedulingClass` | Name of a SchedulingClass CR (cluster-scoped, group cozystack.io) used in place of the tenant's for this application's pods. A pod gets its class when it is created, so running pods keep theirs until they are recreated. Must be the tenant's own class or one listed in the tenant's `allowedSchedulingClasses`. Setting any other value is refused, and the pods of an application whose class is not, or no longer, in that list get the tenant's class. Empty means inherit from the tenant. | `string` | `""` |
|
||||
| Name | Description | Type | Value |
|
||||
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | ----- |
|
||||
| `users` | Users configuration map. Each user is a RabbitMQ user that messaging-topology-operator keeps from an account Secret the platform holds. Passwords are issued through the Cozystack credentials API: a mint on the account's `Credential` (`core.cozystack.io`) returns a new password once, and a revoke retires the password without issuing one. The operator applies either to the broker within seconds. A `password` key here is ignored. The administrator in `<release>-default-user` belongs to the platform and is not shown to tenants. | `map[string]object` | `{}` |
|
||||
| `vhosts` | Virtual hosts configuration map. | `map[string]object` | `{}` |
|
||||
| `vhosts[name].roles` | Virtual host roles list. | `object` | `{}` |
|
||||
| `vhosts[name].roles.admin` | List of admin users. | `[]string` | `[]` |
|
||||
| `vhosts[name].roles.readonly` | List of readonly users. | `[]string` | `[]` |
|
||||
| `schedulingClass` | Name of a SchedulingClass CR (cluster-scoped, group cozystack.io) used in place of the tenant's for this application's pods. A pod gets its class when it is created, so running pods keep theirs until they are recreated. Must be the tenant's own class or one listed in the tenant's `allowedSchedulingClasses`. Setting any other value is refused, and the pods of an application whose class is not, or no longer, in that list get the tenant's class. Empty means inherit from the tenant. | `string` | `""` |
|
||||
|
||||
|
||||
## TLS scope
|
||||
@@ -69,7 +68,7 @@ The broker pods roll once, because the operator mounts the new TLS Secret into t
|
||||
|
||||
And **the published metrics port changes**. The operator exposes *either* `prometheus` (15692) *or* `prometheus-tls` (15691) on its Service, never both — deliberately, so that a scrape config selecting every port does not count each node twice — and that choice keys off TLS alone. Enabling TLS therefore withdraws 15692 from the Service and publishes 15691 in its place. The broker itself keeps listening on 15692, but a `ServiceMonitor` or `VMServiceScrape` selecting the port by the name `prometheus` stops matching. Retarget it to `prometheus-tls`, which is HTTPS under the release CA and so needs a `tlsConfig` carrying the trust anchor described below. The chart does not paper over this by re-adding 15692 through `spec.override.service`: the operator drops any port name it does not own on each reconcile and the override would reinstate it without a NodePort, which on a LoadBalancer means a fresh allocation and another reconcile every round.
|
||||
|
||||
And **the connection details handed to clients change**. `<release>-default-user` is the Service Binding object this chart grants to the tenant, and the operator rewrites its `port` key from `5672` to `5671` as soon as `spec.tls.secretName` is set — gated on TLS alone, not on whether the plaintext listener is still open. A client that hardcodes `:5672` keeps working, because that listener does stay open. A client that resolves its endpoint from the binding — the documented way to consume it — follows the change to 5671 and must speak TLS from then on, and it cannot verify the certificate until the trust anchor below is obtainable. Per-plugin port keys (`mqtt-port`, `stomp-port`, `stream-port` and the web variants) move to their TLS values the same way. This is the main reason `tls.enabled` is opt-in rather than something `external` implies: it moves clients that read the binding correctly, and it moves them the instant the flag is set, before any of them has had a chance to pick up the trust anchor.
|
||||
And **the connection details handed to clients change**. `<release>-default-user` is the operator's Service Binding object, read by platform components such as the backup strategy and no longer by tenants, and the operator rewrites its `port` key from `5672` to `5671` as soon as `spec.tls.secretName` is set — gated on TLS alone, not on whether the plaintext listener is still open. A client that hardcodes `:5672` keeps working, because that listener does stay open. A client that resolves its endpoint from the binding — the documented way to consume it — follows the change to 5671 and must speak TLS from then on, and it cannot verify the certificate until the trust anchor below is obtainable. Per-plugin port keys (`mqtt-port`, `stomp-port`, `stream-port` and the web variants) move to their TLS values the same way. This is the main reason `tls.enabled` is opt-in rather than something `external` implies: it moves clients that read the binding correctly, and it moves them the instant the flag is set, before any of them has had a chance to pick up the trust anchor.
|
||||
|
||||
**The plaintext management listener is load-bearing.** `messaging-topology-operator` is what reconciles the `User`, `Vhost` and `Permission` objects this chart creates from `users` and `vhosts`, and it talks to the broker over the management API. Once TLS is on it would switch to HTTPS on 15671 and verify the broker against the operator process's system certificate pool, which cannot contain a per-release self-signed CA — so every user and permission would fail to reconcile with `certificate signed by unknown authority`. The chart therefore annotates the cluster with `rabbitmq.com/operator-connection-uri` pointing at plaintext `http://…:15672`, keeping that operator on the in-cluster plaintext port. This affects only the operator's own management connection, never broker traffic, and it is why `tls.disableNonTLSListeners` cannot be combined with `users` or `vhosts`.
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
{{/*
|
||||
Account Secret naming, which must match pkg/credentials/account.MapName: the
|
||||
credentials API writes <release>.<account>.account, where <account> is the
|
||||
user name lowercased with every character outside [a-z0-9-] replaced by "-".
|
||||
*/}}
|
||||
{{- define "rabbitmq.accountName" -}}
|
||||
{{- regexReplaceAll "[^a-z0-9-]" (lower .) "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "rabbitmq.accountSecret" -}}
|
||||
{{- $root := index . 0 -}}
|
||||
{{- $user := index . 1 -}}
|
||||
{{- printf "%s.%s.account" $root.Release.Name (include "rabbitmq.accountName" $user) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Two users mapping to one account would share one Secret, so the topology
|
||||
operator would import the same credentials for both User objects.
|
||||
*/}}
|
||||
{{- define "rabbitmq.accountsGuard" -}}
|
||||
{{- $seen := dict -}}
|
||||
{{- range $user, $_ := .Values.users -}}
|
||||
{{- $mapped := include "rabbitmq.accountName" $user -}}
|
||||
{{- if or (gt (len $mapped) 63) (not (regexMatch "^[a-z0-9]([-a-z0-9]*[a-z0-9])?$" $mapped)) -}}
|
||||
{{- fail (printf "user %q maps to the account name %q, which must be at most 63 characters and start and end with a letter or a digit; rename the user" $user $mapped) -}}
|
||||
{{- end -}}
|
||||
{{- with index $seen $mapped -}}
|
||||
{{- fail (printf "users %q and %q both map to the account name %q; rename one of them" . $user $mapped) -}}
|
||||
{{- end -}}
|
||||
{{- $_ := set $seen $mapped $user -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,25 @@
|
||||
{{- /*
|
||||
One CredentialTemplate per user: the account the Cozystack credentials API
|
||||
mints and revokes through. cozystack-controller keeps its account Secret,
|
||||
<release>.<account>.account, which the User's importCredentialsSecret names
|
||||
in rabbitmq.yaml. messaging-topology-operator watches that Secret and puts
|
||||
the password to the broker again whenever it changes, so a mint applies
|
||||
without a Helm run. The operator reads the plaintext and hashes it itself,
|
||||
hence the plaintext format; the label is the one its Secret cache and its
|
||||
User admission webhook require. The chart renders no password.
|
||||
*/ -}}
|
||||
{{- include "rabbitmq.accountsGuard" $ }}
|
||||
{{- range $user, $_ := .Values.users }}
|
||||
---
|
||||
apiVersion: cozystack.io/v1alpha1
|
||||
kind: CredentialTemplate
|
||||
metadata:
|
||||
name: {{ printf "%s.%s" $.Release.Name (include "rabbitmq.accountName" $user) | quote }}
|
||||
spec:
|
||||
username: {{ $user | quote }}
|
||||
format:
|
||||
name: plaintext
|
||||
secret:
|
||||
labels:
|
||||
rabbitmq.com/topology-operator: "true"
|
||||
{{- end }}
|
||||
@@ -129,44 +129,24 @@ spec:
|
||||
{{- end }}
|
||||
storage: {{ .Values.size }}
|
||||
|
||||
{{- range $user, $u := .Values.users }}
|
||||
|
||||
{{- $password := $u.password }}
|
||||
{{- if not $password }}
|
||||
{{- with (dig "data" "password" "" (lookup "v1" "Secret" $.Release.Namespace (printf "%s-%s-credentials" $.Release.Name (kebabcase $user)))) }}
|
||||
{{- $password = b64dec . }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if not $password }}
|
||||
{{- $password = (randAlphaNum 16) }}
|
||||
{{- end }}
|
||||
|
||||
{{- /* The User object keeps its pre-conversion name: renaming it would make
|
||||
the operator delete the broker user and create it again. Its password
|
||||
comes from the account Secret of credentials.yaml, which the operator
|
||||
re-imports on every change. Until the Secret exists the operator's
|
||||
admission webhook refuses the User, so a release that adds a user
|
||||
converges on the retry after cozystack-controller has seeded it. */}}
|
||||
{{- include "rabbitmq.accountsGuard" $ }}
|
||||
{{- range $user, $_ := .Values.users }}
|
||||
---
|
||||
apiVersion: rabbitmq.com/v1beta1
|
||||
kind: User
|
||||
metadata:
|
||||
name: {{ $.Release.Name }}-{{ kebabcase $user }}
|
||||
annotations:
|
||||
config: '{{ printf "%s %s" $user $password | sha256sum }}'
|
||||
spec:
|
||||
importCredentialsSecret:
|
||||
name: {{ $.Release.Name }}-{{ kebabcase $user }}-credentials
|
||||
name: {{ include "rabbitmq.accountSecret" (list $ $user) | quote }}
|
||||
rabbitmqClusterReference:
|
||||
name: {{ $.Release.Name }}
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ $.Release.Name }}-{{ kebabcase $user }}-credentials
|
||||
labels:
|
||||
apps.cozystack.io/user-secret: "true"
|
||||
# Topology Operator >= 1.20 caches only Secrets carrying this label, and its User
|
||||
# admission webhook rejects an importCredentialsSecret that lacks it.
|
||||
rabbitmq.com/topology-operator: "true"
|
||||
type: Opaque
|
||||
stringData:
|
||||
username: {{ $user }}
|
||||
password: {{ $password }}
|
||||
{{- end }}
|
||||
|
||||
{{- range $host, $h := .Values.vhosts }}
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
suite: one CredentialTemplate per user, naming the account Secret the User imports
|
||||
|
||||
# The template is the account the credentials API mints through; its name plus
|
||||
# ".account" must be the importCredentialsSecret rabbitmq.yaml gives the User,
|
||||
# or the topology operator reads a Secret nobody writes.
|
||||
|
||||
templates:
|
||||
- templates/credentials.yaml
|
||||
|
||||
release:
|
||||
name: rabbitmq-test
|
||||
namespace: tenant-test
|
||||
|
||||
tests:
|
||||
- it: renders nothing without users
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 0
|
||||
|
||||
- it: renders a template per user, named for the account Secret's mapping
|
||||
set:
|
||||
users:
|
||||
web: {}
|
||||
Bob.Smith: {}
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 2
|
||||
- isKind:
|
||||
of: CredentialTemplate
|
||||
- equal:
|
||||
path: apiVersion
|
||||
value: cozystack.io/v1alpha1
|
||||
- equal:
|
||||
path: metadata.name
|
||||
value: rabbitmq-test.bob-smith
|
||||
documentIndex: 0
|
||||
- equal:
|
||||
path: spec.username
|
||||
value: Bob.Smith
|
||||
documentIndex: 0
|
||||
- equal:
|
||||
path: metadata.name
|
||||
value: rabbitmq-test.web
|
||||
documentIndex: 1
|
||||
|
||||
- it: stores the plaintext the operator hashes, labelled for its Secret cache
|
||||
set:
|
||||
users:
|
||||
web: {}
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.format.name
|
||||
value: plaintext
|
||||
- equal:
|
||||
path: spec.secret.labels
|
||||
value:
|
||||
rabbitmq.com/topology-operator: "true"
|
||||
- notExists:
|
||||
path: spec.valuesPath
|
||||
|
||||
- it: refuses two users that map to one account
|
||||
set:
|
||||
users:
|
||||
web: {}
|
||||
Web: {}
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorPattern: map to
|
||||
|
||||
- it: refuses a user that maps to no valid account name
|
||||
set:
|
||||
users:
|
||||
"-web": {}
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorPattern: start and end with a letter or a digit
|
||||
|
||||
- it: refuses a user whose account name is longer than a DNS label
|
||||
set:
|
||||
users:
|
||||
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: {}
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorPattern: at most 63 characters
|
||||
@@ -1,4 +1,4 @@
|
||||
suite: RabbitMQ user credentials Secrets
|
||||
suite: RabbitMQ users read their password from the account Secret
|
||||
|
||||
templates:
|
||||
- templates/rabbitmq.yaml
|
||||
@@ -7,20 +7,19 @@ release:
|
||||
name: myrabbitmq
|
||||
namespace: tenant-test
|
||||
|
||||
# messaging-topology-operator >= 1.20 caches only Secrets labelled
|
||||
# rabbitmq.com/topology-operator=true, and its User admission webhook rejects an
|
||||
# importCredentialsSecret that lacks the label. Losing it rejects every User the
|
||||
# chart renders.
|
||||
# messaging-topology-operator re-imports importCredentialsSecret whenever the
|
||||
# Secret changes, so pointing each User at the account Secret the credentials
|
||||
# API writes is what makes a mint reach the broker. The User keeps its
|
||||
# pre-conversion name: renaming it would make the operator delete the broker
|
||||
# user and create it again.
|
||||
|
||||
set:
|
||||
users:
|
||||
alice:
|
||||
password: alicepassword
|
||||
bobSmith:
|
||||
password: bobpassword
|
||||
alice: {}
|
||||
bobSmith: {}
|
||||
|
||||
tests:
|
||||
- it: points each User at its own credentials Secret
|
||||
- it: points each User at its account Secret and keeps its name
|
||||
documentSelector:
|
||||
path: metadata.name
|
||||
value: myrabbitmq-bob-smith
|
||||
@@ -29,15 +28,38 @@ tests:
|
||||
of: User
|
||||
- equal:
|
||||
path: spec.importCredentialsSecret.name
|
||||
value: myrabbitmq-bob-smith-credentials
|
||||
value: myrabbitmq.bobsmith.account
|
||||
- notExists:
|
||||
path: metadata.annotations
|
||||
|
||||
- it: labels every credentials Secret for the topology operator's Secret cache
|
||||
documentSelector:
|
||||
path: kind
|
||||
value: Secret
|
||||
matchMany: true
|
||||
- it: renders no Secret, so no password reaches the release
|
||||
asserts:
|
||||
- equal:
|
||||
path: metadata.labels["rabbitmq.com/topology-operator"]
|
||||
value: "true"
|
||||
- containsDocument:
|
||||
kind: Secret
|
||||
apiVersion: v1
|
||||
not: true
|
||||
|
||||
- it: ignores a password left in values
|
||||
set:
|
||||
users:
|
||||
alice:
|
||||
password: alicepassword
|
||||
asserts:
|
||||
- containsDocument:
|
||||
kind: Secret
|
||||
apiVersion: v1
|
||||
not: true
|
||||
- notExists:
|
||||
path: metadata.annotations.config
|
||||
documentSelector:
|
||||
path: metadata.name
|
||||
value: myrabbitmq-alice
|
||||
|
||||
- it: refuses two users that map to one account
|
||||
set:
|
||||
users:
|
||||
web: {}
|
||||
Web: {}
|
||||
asserts:
|
||||
- failedTemplate:
|
||||
errorPattern: map to
|
||||
@@ -160,17 +160,11 @@
|
||||
]
|
||||
},
|
||||
"users": {
|
||||
"description": "Users configuration map.",
|
||||
"description": "Users configuration map. Each user is a RabbitMQ user that messaging-topology-operator keeps from an account Secret the platform holds. Passwords are issued through the Cozystack credentials API: a mint on the account's `Credential` (`core.cozystack.io`) returns a new password once, and a revoke retires the password without issuing one. The operator applies either to the broker within seconds. A `password` key here is ignored. The administrator in `\u003crelease\u003e-default-user` belongs to the platform and is not shown to tenants.",
|
||||
"type": "object",
|
||||
"default": {},
|
||||
"additionalProperties": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"password": {
|
||||
"description": "Password for the user.",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"vhosts": {
|
||||
|
||||
@@ -102,18 +102,13 @@ version: v4.2
|
||||
##
|
||||
|
||||
## @typedef {struct} User - User configuration.
|
||||
## @field {string} [password] - Password for the user.
|
||||
|
||||
## @param {map[string]User} users - Users configuration map.
|
||||
## @param {map[string]User} users - Users configuration map. Each user is a RabbitMQ user that messaging-topology-operator keeps from an account Secret the platform holds. Passwords are issued through the Cozystack credentials API: a mint on the account's `Credential` (`core.cozystack.io`) returns a new password once, and a revoke retires the password without issuing one. The operator applies either to the broker within seconds. A `password` key here is ignored. The administrator in `<release>-default-user` belongs to the platform and is not shown to tenants.
|
||||
users: {}
|
||||
## Example:
|
||||
## users:
|
||||
## user1:
|
||||
## password: strongpassword
|
||||
## user2:
|
||||
## password: hackme
|
||||
## user3:
|
||||
## password: testtest
|
||||
## user1: {}
|
||||
## user2: {}
|
||||
|
||||
## @typedef {struct} Roles - Virtual host roles.
|
||||
## @field {[]string} [admin] - List of admin users.
|
||||
|
||||
+8
-7
@@ -8,7 +8,7 @@ spec:
|
||||
plural: rabbitmqs
|
||||
singular: rabbitmq
|
||||
openAPISchema: |-
|
||||
{"title":"Chart Values","type":"object","properties":{"replicas":{"description":"Number of RabbitMQ replicas.","type":"integer","default":3},"resources":{"description":"Explicit CPU and memory configuration for each RabbitMQ replica. Every resource left unset here is taken from `resourcesPreset`.","type":"object","default":{},"properties":{"cpu":{"description":"CPU available to each replica.","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true},"memory":{"description":"Memory (RAM) available to each replica.","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true}}},"resourcesPreset":{"description":"Default sizing preset. It supplies every resource `resources` does not set, not only a `resources` left empty entirely.","type":"string","default":"s1.nano","enum":["t1.nano","t1.micro","t1.small","t1.medium","t1.large","t1.xlarge","t1.2xlarge","t1.4xlarge","c1.nano","c1.micro","c1.small","c1.medium","c1.large","c1.xlarge","c1.2xlarge","c1.4xlarge","s1.nano","s1.micro","s1.small","s1.medium","s1.large","s1.xlarge","s1.2xlarge","s1.4xlarge","u1.nano","u1.micro","u1.small","u1.medium","u1.large","u1.xlarge","u1.2xlarge","u1.4xlarge","m1.nano","m1.micro","m1.small","m1.medium","m1.large","m1.xlarge","m1.2xlarge","m1.4xlarge","nano","micro","small","medium","large","xlarge","2xlarge"]},"size":{"description":"Persistent Volume Claim size available for application data.","default":"10Gi","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true},"storageClass":{"description":"StorageClass used to store the data.","type":"string","default":"","x-kubernetes-validations":[{"rule":"self == oldSelf","message":"storageClass is immutable"}],"x-cozystack-options":{"source":"storageclass"}},"external":{"description":"Enable external access from outside the cluster.","type":"boolean","default":false},"affinity":{"description":"Pod affinity applied to RabbitMQ pods (standard Kubernetes corev1.Affinity). Use podAntiAffinity with topologyKey `kubernetes.io/hostname` to spread RabbitMQ pods across nodes.","type":"object","default":{},"x-kubernetes-preserve-unknown-fields":true},"tls":{"description":"TLS configuration. TLS is off unless `tls.enabled` is set to true.","type":"object","default":{},"properties":{"disableNonTLSListeners":{"description":"Close the plaintext AMQP (5672) and management (15672) listeners. This is a broker-level switch: it drops in-cluster clients as well as external ones, and it cannot be combined with `users` or `vhosts`. Erlang distribution (25672) and epmd (4369) stay plaintext regardless. Defaults to false.","type":"boolean"},"enabled":{"description":"Enable TLS for AMQPS (5671) and Management HTTPS (15671). Applies whether or not `external` is set. Plaintext AMQP (5672) and management (15672) keep serving unless `disableNonTLSListeners` is set as well. Moves the `port` key of the `<release>-default-user` Secret from 5672 to 5671, and the metrics port from 15692 to 15691. Defaults to false.","type":"boolean"}}},"version":{"description":"RabbitMQ major.minor version to deploy","type":"string","default":"v4.2","enum":["v4.2","v4.1","v4.0","v3.13"]},"users":{"description":"Users configuration map.","type":"object","default":{},"additionalProperties":{"type":"object","properties":{"password":{"description":"Password for the user.","type":"string"}}}},"vhosts":{"description":"Virtual hosts configuration map.","type":"object","default":{},"additionalProperties":{"type":"object","required":["roles"],"properties":{"roles":{"description":"Virtual host roles list.","type":"object","properties":{"admin":{"description":"List of admin users.","type":"array","items":{"type":"string"}},"readonly":{"description":"List of readonly users.","type":"array","items":{"type":"string"}}}}}}},"schedulingClass":{"description":"Name of a SchedulingClass CR (cluster-scoped, group cozystack.io) used in place of the tenant's for this application's pods. A pod gets its class when it is created, so running pods keep theirs until they are recreated. Must be the tenant's own class or one listed in the tenant's `allowedSchedulingClasses`. Setting any other value is refused, and the pods of an application whose class is not, or no longer, in that list get the tenant's class. Empty means inherit from the tenant.","type":"string","default":"","maxLength":63}}}
|
||||
{"title":"Chart Values","type":"object","properties":{"replicas":{"description":"Number of RabbitMQ replicas.","type":"integer","default":3},"resources":{"description":"Explicit CPU and memory configuration for each RabbitMQ replica. Every resource left unset here is taken from `resourcesPreset`.","type":"object","default":{},"properties":{"cpu":{"description":"CPU available to each replica.","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true},"memory":{"description":"Memory (RAM) available to each replica.","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true}}},"resourcesPreset":{"description":"Default sizing preset. It supplies every resource `resources` does not set, not only a `resources` left empty entirely.","type":"string","default":"s1.nano","enum":["t1.nano","t1.micro","t1.small","t1.medium","t1.large","t1.xlarge","t1.2xlarge","t1.4xlarge","c1.nano","c1.micro","c1.small","c1.medium","c1.large","c1.xlarge","c1.2xlarge","c1.4xlarge","s1.nano","s1.micro","s1.small","s1.medium","s1.large","s1.xlarge","s1.2xlarge","s1.4xlarge","u1.nano","u1.micro","u1.small","u1.medium","u1.large","u1.xlarge","u1.2xlarge","u1.4xlarge","m1.nano","m1.micro","m1.small","m1.medium","m1.large","m1.xlarge","m1.2xlarge","m1.4xlarge","nano","micro","small","medium","large","xlarge","2xlarge"]},"size":{"description":"Persistent Volume Claim size available for application data.","default":"10Gi","pattern":"^(\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\\+|-)?(([0-9]+(\\.[0-9]*)?)|(\\.[0-9]+))))?$","anyOf":[{"type":"integer"},{"type":"string"}],"x-kubernetes-int-or-string":true},"storageClass":{"description":"StorageClass used to store the data.","type":"string","default":"","x-kubernetes-validations":[{"rule":"self == oldSelf","message":"storageClass is immutable"}],"x-cozystack-options":{"source":"storageclass"}},"external":{"description":"Enable external access from outside the cluster.","type":"boolean","default":false},"affinity":{"description":"Pod affinity applied to RabbitMQ pods (standard Kubernetes corev1.Affinity). Use podAntiAffinity with topologyKey `kubernetes.io/hostname` to spread RabbitMQ pods across nodes.","type":"object","default":{},"x-kubernetes-preserve-unknown-fields":true},"tls":{"description":"TLS configuration. TLS is off unless `tls.enabled` is set to true.","type":"object","default":{},"properties":{"disableNonTLSListeners":{"description":"Close the plaintext AMQP (5672) and management (15672) listeners. This is a broker-level switch: it drops in-cluster clients as well as external ones, and it cannot be combined with `users` or `vhosts`. Erlang distribution (25672) and epmd (4369) stay plaintext regardless. Defaults to false.","type":"boolean"},"enabled":{"description":"Enable TLS for AMQPS (5671) and Management HTTPS (15671). Applies whether or not `external` is set. Plaintext AMQP (5672) and management (15672) keep serving unless `disableNonTLSListeners` is set as well. Moves the `port` key of the `<release>-default-user` Secret from 5672 to 5671, and the metrics port from 15692 to 15691. Defaults to false.","type":"boolean"}}},"version":{"description":"RabbitMQ major.minor version to deploy","type":"string","default":"v4.2","enum":["v4.2","v4.1","v4.0","v3.13"]},"users":{"description":"Users configuration map. Each user is a RabbitMQ user that messaging-topology-operator keeps from an account Secret the platform holds. Passwords are issued through the Cozystack credentials API: a mint on the account's `Credential` (`core.cozystack.io`) returns a new password once, and a revoke retires the password without issuing one. The operator applies either to the broker within seconds. A `password` key here is ignored. The administrator in `<release>-default-user` belongs to the platform and is not shown to tenants.","type":"object","default":{},"additionalProperties":{"type":"object"}},"vhosts":{"description":"Virtual hosts configuration map.","type":"object","default":{},"additionalProperties":{"type":"object","required":["roles"],"properties":{"roles":{"description":"Virtual host roles list.","type":"object","properties":{"admin":{"description":"List of admin users.","type":"array","items":{"type":"string"}},"readonly":{"description":"List of readonly users.","type":"array","items":{"type":"string"}}}}}}},"schedulingClass":{"description":"Name of a SchedulingClass CR (cluster-scoped, group cozystack.io) used in place of the tenant's for this application's pods. A pod gets its class when it is created, so running pods keep theirs until they are recreated. Must be the tenant's own class or one listed in the tenant's `allowedSchedulingClasses`. Setting any oLine truncated
|
||||
release:
|
||||
prefix: rabbitmq-
|
||||
labels:
|
||||
@@ -40,16 +40,19 @@ spec:
|
||||
# Bounded, not absolute: matching is exact-name with no globs, so a Secret a
|
||||
# future operator version introduces stays in scope of the label-only
|
||||
# include. The primary defence is the lineage webhook stamping only what it
|
||||
# can attribute; this closes the enumerable set. -default-user is excluded
|
||||
# from the exclusion on purpose — it is included by name below.
|
||||
# can attribute; this closes the enumerable set.
|
||||
#
|
||||
# -default-user holds the administrator messaging-topology-operator logs
|
||||
# in with, a platform account no tenant reads. The tenant accounts live in
|
||||
# account Secrets that no definition selects: the credentials API shows a
|
||||
# password once, in the response of the mint that issued it.
|
||||
exclude:
|
||||
- resourceNames:
|
||||
- rabbitmq-{{ .name }}-ca
|
||||
- rabbitmq-{{ .name }}-tls
|
||||
- rabbitmq-{{ .name }}-erlang-cookie
|
||||
include:
|
||||
- resourceNames:
|
||||
- rabbitmq-{{ .name }}-default-user
|
||||
include:
|
||||
# The key-free trust anchor the CA-extraction controller publishes. The
|
||||
# chart names its own CA Secret in a TenantProjection sentinel, and the
|
||||
# controller stamps this label on the projection it writes from that
|
||||
@@ -58,8 +61,6 @@ spec:
|
||||
# engine shares; it carries no per-release name templating.
|
||||
- matchLabels:
|
||||
internal.cozystack.io/tenant-ca: "true"
|
||||
- matchLabels:
|
||||
apps.cozystack.io/user-secret: "true"
|
||||
services:
|
||||
exclude: []
|
||||
include:
|
||||
|
||||
@@ -2369,6 +2369,7 @@ var removedUserPasswordKinds = map[string]string{
|
||||
mariadbKind: mintedPasswordWarning,
|
||||
clickhouseKind: mintedPasswordWarning,
|
||||
mongodbKind: mintedPasswordWarning,
|
||||
rabbitmqKind: mintedPasswordWarning,
|
||||
}
|
||||
|
||||
// mintedPasswordWarning is the warning of a kind whose user passwords the
|
||||
@@ -2379,6 +2380,7 @@ const mintedPasswordWarning = "spec.users[%q].password is ignored: passwords are
|
||||
const (
|
||||
clickhouseKind = "ClickHouse"
|
||||
mongodbKind = "MongoDB"
|
||||
rabbitmqKind = "RabbitMQ"
|
||||
postgresKind = "Postgres"
|
||||
mariadbKind = "MariaDB"
|
||||
)
|
||||
|
||||
@@ -164,6 +164,7 @@ func TestWarnRemovedUserPasswords(t *testing.T) {
|
||||
}{
|
||||
{"postgres warns", postgresKind, rawWithPassword, true},
|
||||
{"mariadb warns", mariadbKind, rawWithPassword, true},
|
||||
{"rabbitmq warns", rabbitmqKind, rawWithPassword, true},
|
||||
{"mongodb warns", mongodbKind, rawWithPassword, true},
|
||||
{"clickhouse warns", clickhouseKind, rawWithPassword, true},
|
||||
{"other kind stays quiet", "Redis", rawWithPassword, false},
|
||||
@@ -197,7 +198,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, clickhouseKind, mariadbKind, mongodbKind} {
|
||||
for _, kind := range []string{postgresKind, clickhouseKind, mariadbKind, mongodbKind, rabbitmqKind} {
|
||||
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