Skip to content

Commit 58d496c

Browse files
committed
Add examples for hash-based User creation
userWithPasswordHash.yaml - Creating a User with SHA-512 hash. passwordlessUser.yaml - Creating a User with empty hash. Password field is ignored, paswordless user is created.
1 parent b315eaf commit 58d496c

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

docs/examples/users/README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
# User examples
22

3-
This section contains 3 examples for creating RabbitMQ users.
4-
Messaging Topology Operator creates users with generated credentials by default. To create RabbitMQ users with provided credentials, you can reference a kubernetes secret object contains keys `username` and `password` in its Data field.
5-
See [userPreDefinedCreds.yaml](./userPreDefinedCreds.yaml) and [publish-consume-user.yaml](./publish-consume-user.yaml) as examples.
3+
This section contains the examples for creating RabbitMQ users.
4+
5+
Messaging Topology Operator creates users with generated credentials by default. To create RabbitMQ users with provided credentials, you can reference a kubernetes secret object with the following keys in its Data field:
6+
7+
* `username` – Must be present or the import will fail.
8+
* `passwordHash` – The SHA-512 hash of the password, as described in [RabbitMQ Docs](https://www.rabbitmq.com/docs/passwords). If the hash is an empty string, a passwordless user will be created.
9+
* `password` – Plain-text password. Will be used only if the `passwordHash` key is missing.
10+
11+
See [userPreDefinedCreds.yaml](./userPreDefinedCreds.yaml), [userWithPasswordHash.yaml](userWithPasswordHash.yaml), [passwordlessUser.yaml](passwordlessUser.yaml) and [publish-consume-user.yaml](./publish-consume-user.yaml) as examples.
12+
613
From [Messaging Topology Operator v1.10.0](https://github.com/rabbitmq/messaging-topology-operator/releases/tag/v1.10.1), you can provide a username and reply on the Operator to generate its password for you.
714
See [setUsernamewithGenPass.yaml](./setUsernamewithGenPass.yaml) as an example.
815

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: credentials-secret
5+
type: Opaque
6+
stringData:
7+
username: import-user-sample
8+
passwordHash: "" # The user will not have a valid password. Login attempts with any password will be rejected
9+
password: anythingreally # This value will be ignored, because `passwordHash` takes precedence
10+
---
11+
apiVersion: rabbitmq.com/v1beta1
12+
kind: User
13+
metadata:
14+
name: import-user-sample
15+
spec:
16+
tags:
17+
- management # available tags are 'management', 'policymaker', 'monitoring' and 'administrator'
18+
- policymaker
19+
rabbitmqClusterReference:
20+
name: test # rabbitmqCluster must exist in the same namespace as this resource
21+
importCredentialsSecret:
22+
name: credentials-secret
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: credentials-secret
5+
type: Opaque
6+
stringData:
7+
username: import-user-sample
8+
passwordHash: SjWbNXaNEwcoOOZWxG6J1HCF5P83lUavsCto+wh1s9zdOfoZ/CPv6l/SSdK3RC2+1QWmJGdYt5740j3ZLf/0RbpusNc= # SHA-512 hash of "some-password"
9+
---
10+
apiVersion: rabbitmq.com/v1beta1
11+
kind: User
12+
metadata:
13+
name: import-user-sample
14+
spec:
15+
tags:
16+
- management # available tags are 'management', 'policymaker', 'monitoring' and 'administrator'
17+
- policymaker
18+
rabbitmqClusterReference:
19+
name: test # rabbitmqCluster must exist in the same namespace as this resource
20+
importCredentialsSecret:
21+
name: credentials-secret

0 commit comments

Comments
 (0)