-
Hi everyone, bootstrapConfig: |
authentication {
backend = "built_in_database"
mechanism = "password_based"
password_hash_algorithm {name = "sha256", salt_position = "suffix"}
user_id_type = "username"
} But now I don't know how to create the user. Is the REST API the only way? Thanks in advance :) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
I was able to configure it using a sidecar which execute a POST when the server is ready but I don't like to keep a container running and honestly I suspect there is another way which could simplify this process: apiVersion: apps.emqx.io/v2alpha1
kind: EMQX
metadata:
name: emqx
spec:
image: emqx/emqx:5.0.9
coreTemplate:
spec:
envFrom:
- secretRef:
name: dashboard-auth
extraContainers:
- name: users-creation
image: centos:latest
envFrom:
- secretRef:
name: dashboard-auth
volumeMounts:
- name: mqtt-users
readOnly: true
mountPath: "/etc/mqtt-users"
command:
- /bin/bash
- -c
- |
echo "waiting web server to be ready"
until $(curl --output /dev/null --silent --fail \
-u $EMQX_DASHBOARD__DEFAULT_USERNAME:$EMQX_DASHBOARD__DEFAULT_PASSWORD \
http://localhost:18083/api/v5/monitor_current); do
printf '.'
sleep 5
done
echo "creating users..."
curl --output /dev/null --silent \
-u $EMQX_DASHBOARD__DEFAULT_USERNAME:$EMQX_DASHBOARD__DEFAULT_PASSWORD \
-X POST \
-d @/etc/mqtt-users/users.json \
'http://localhost:18083/api/v5/authentication/password_based%3Abuilt_in_database/users' \
-H 'Content-Type: application/json'
echo "done"
sleep infinity
extraVolumes:
- name: mqtt-users
secret:
secretName: mqtt-users Please let me know if you have any suggestion :) |
Beta Was this translation helpful? Give feedback.
-
Hi, @raelix |
Beta Was this translation helpful? Give feedback.
Hi, @raelix
You can also bulk import users via the REST API, which requires
POST /authentication/{id}/import_users
.