emqx / emqx-docs

EMQX product documentation
https://docs.emqx.com/
156 stars 264 forks source link

plugin auth-mnesia depends on emqx_auth_username #795

Closed qzhuyan closed 3 years ago

qzhuyan commented 3 years ago

File: /en_US/advanced/auth-mnesia.md

User reports emqx_auth_mnesia plugin not working when the plugin emqx_auth_username is not enabled. This page should describe emqx_auth_mnesia depends on emqx_auth_username and both of them should be enabled in the Plugins page.

zmstone commented 3 years ago

Which version ?

qzhuyan commented 3 years ago

4.2.0 https://emqx.slack.com/archives/CBUF2TTB8/p1623427232034200

jjauzion commented 3 years ago

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
qzhuyan commented 3 years ago

@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}'
jjauzion commented 3 years ago

@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:

thanks :)

qzhuyan commented 3 years ago

@alexsuppanz I close the ticket now. move issue tracking to #800