随笔 - 495  文章 - 1  评论 - 17  阅读 - 38万

EMQX_AUTH_USERNAME 使用指南

在阅读该教程之前,假定你已经了解 MQTTEMQX 的简单知识。

emqx_auth_username 它通过比对每个终端的接入的 usernamepassword 与 EMQ X 中存储的是否一致来实现终端接入的控制。其功能逻辑如下:

emqx_auth_username 目前版本仅提供了 连接认证 的功能。且提供了 CLIREST API 来进行管理当前集群中的 Username 库

插件配置项说明

在这里给出了其 3.1.0 版本默认的配置文件。其内容非常的简单,主要包括:

1.Password 密文加密类型

终端在连接时,必须采用对用加密类型的密文才可以成功连接

## Password hash.
##
## Value: plain | md5 | sha | sha256
auth.user.password_hash = sha256

Username 管理

CLI 命令

在成功启动 emqx_auth_username 该插件时,会向 EMQ X 注册一些 CLI 命令以在运行时管理 username:

$ ./bin/emqx_ctl users

users list                                     
users add <Username> <Password>                
users update <Username> <NewPassword>          
users del <Username>                           

REST API

在成功启动 emqx_auth_username 该插件时,会开启对应的 REST API 用于在运行时管理 username

获取所有的 username

# Request
GET api/v3/auth_username

# Response
{
   "code": 0,
   "data": ["username1"]
}

添加一个 username:

# Request
POST api/v3/auth_username
{
   "username": "some_name",
   "password": "password"
}

# Response
{
   "code": 0
}

更新某 username 的密码 :

# Request
PUT api/v3/auth_username/$NAME
{
   "password": "password"
}

# Response
{
   "code", 0
}

查看某 username 的密码 (密文):

# Request
GET api/v3/auth_username/$NAME

# Response
{
   "code": 0,
   "data": {
       "username": "some_username",
       "password": "hashed_password"
   }
}

删除某 username:

# Request
DELETE api/v3/auth_username/$NAME

# Response
{
   "code": 0
}
posted on   EMQX  阅读(1625)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示