前言
emqx可以做连接认证回调验证
http回调
文档为
ruby
https://docs.emqx.com/zh/emqx/latest/guides/access-control/authn/http.html
emqx密码认证回调
1、访问emqx界面
arduino
http://localhost:18083/
登录进去,默认账号是"admin",密码为"public"
2、选择Authentication菜单

3、点击Create按钮
出现
默认选择Password-Base
点击Next
url填写为http://127.0.0.1:8080/hello,看自己服务器的回调地址,这里新增一个clientid
点击Create按钮,创建之后为
如果服务没启动的话,就会显示
写一个回调接口
less
@RestController
@RequestMapping("/hello")
public class HelloController {
private static final Logger log = LoggerFactory.getLogger(HelloController.class);
@PostMapping
public HelloResponse hello(@RequestBody AuthRequestBody body) {
// 日志不打印密码明文,只打印长度
log.info("[hello] clientid={}, username={}, passwordLen={}",
body.clientid(), body.username(),
body.password() == null ? 0 : body.password());
return new HelloResponse("Hello, " + body.username() + "!", body.clientid(), body.username(), Instant.now());
}
/**
* 请求体:字段名与 EMQX body 模板占位符一一对应。
*/
public record AuthRequestBody(String clientid, String password, String username) {
}
public record SHelloResponse(String message, String clientid, String username, Instant receivedAt) {
}
}
然后客户端连接之后
连接之后,便会携带参数到接口认证

总结
可以使用emqx做回调认证