Closed qzhuyan closed 3 years ago
Which version ?
to be more specific it’s the mnesia HTTP API that doesn’t work:
POST api/v4/auth_user
{
"login": "emqx_c",
"password": "emqx_p",
"is_superuser": false
}
got 404: not_found
but when activating emqx_auth_username I can use:
POST api/v4/auth_username
{
"username": "emqx_u",
"password": "emqx_p"
}
and I’m just seeing that it’s actually not the same endpoint so I guess I didn’t fix mnesia endpoints but I’m just using another solution than mnesia ? If so then I don't understand why mnesia endpoints are not working
Here is my docker-compose if you wanna try:
emqx1:
image: emqx/emqx:4.2.0
environment:
- EMQX_NAME=emqx
- EMQX_HOST=node1.emqx.io
- EMQX_NODE__NAME=emqx.local.node
- EMQX_RETAINER__STORAGE_TYPE=disc
- EMQX_LOADED_PLUGINS="emqx_management,emqx_recon,emqx_retainer,emqx_dashboard,emqx_auth_username,emqx_auth_mnesia"
- EMQX_AUTH__MNESIA__PASSWORD_HASH=sha256
- EMQX_AUTH__MNESIA__1__LOGIN=bootstrap
- EMQX_AUTH__MNESIA__1__PASSWORD=public
- EMQX_AUTH__MNESIA__1__IS_SUPERUSER=true
- EMQX_ALLOW_ANONYMOUS=false
volumes:
- emqx-data:/opt/emqx/data
- emqx-etc:/opt/emqx/etc
- emqx-log:/opt/emqx/log
ports:
- 18083:18083
- "${GW_EMQX_PORT:?err}:${GW_EMQX_PORT:?err}"
- "${GW_EMQX_API_PORT:?err}:${GW_EMQX_API_PORT:?err}"
networks:
gateway-api:
aliases:
- node1.emqx.io
@jjauzion thanks for your updates, looks like the endpoint is incorrect, this piece of information is missing in doc.
endpoint should be api/v4/mqtt_user
can you try with following?
curl -X POST -u admin:public 127.0.0.1:8081/api/v4/mqtt_user -d '{ "login": "emqx_c", "password" : "emqx_p", "is_superuser":false}'
@qzhuyan thx for your help, that works ! So in the end it is just a doc update needed I guess.
Some few comments if I may:
another error I was doing passing the login
, password
and is_superuser
by params instead of as a json body (see below). Would be nice if the doc was more clear on this.
curl -X POST -u admin:public "127.0.0.1:8081/api/v4/mqtt_user?login=emqx_u&password=emqx_p&is_superus=false"
yield a weird error:
{"data":{"mqx_u":"{error,is_superuser}"},"code":0}
if I use "username" instead of "login", I got an internal error
instead of a bad request error
I tried using the v4.3.3 but the endpoints is not same and the doc endpoints seems wrong also. I've seen some open issue on this topic but was unable to find the working endpoint for the v4.3.3. Do you know what is the good endpoint for mnesia?
thanks :)
@alexsuppanz I close the ticket now. move issue tracking to #800
File: /en_US/advanced/auth-mnesia.md
User reports
emqx_auth_mnesia
plugin not working when the pluginemqx_auth_username
is not enabled. This page should describeemqx_auth_mnesia
depends onemqx_auth_username
and both of them should be enabled in the Plugins page.