emqx_auth_http ACL 设置不起作用

环境信息

  • EMQX 版本:EMQ X Broker:4.3.5
  • 操作系统及版本:CentOS 8
  • 其他

问题描述

在 etc/plugins/emqx_auth_http.conf 文件中做了相应的设置
在java 中也设置了相应的接口文件,接口文件通过postman访问都没有问题;
其中 /mqtt/auth 好用;/mqtt/acl 不好用;
@Path("/mqtt")
#POST
#Path("/auth")
#Produces({ MediaType.APPLICATION_JSON })
#Consumes({ MediaType.APPLICATION_JSON })
Object mqttLoginAuth(JSONObject request) throws BusinessException;

#POST
#Path("/acl")
#Produces({ MediaType.APPLICATION_JSON })
#Consumes({ "application/x-www-form-urlencoded" })
Object mqttACL(#FormParam("access") String access, #FormParam("username") String username,
		#FormParam("clientid") String clientid, #FormParam("topic") String topic) throws Exception;

public Object mqttACL(String access, String username, String clientid, String topic) throws BusinessException {
	logger.info(String.format("mqttACL_Result: 进入:" + clientid + ":" + access + ":" + username + ":" + topic));
	// logger.info("mqttACLmqttACLmqttACL:"+request.toString());
	throw new BusinessException("mqttACL err");

配置文件及日志


看起来确实是没有发起请求。用下面命令,拿一下系统中挂载的 check_acl 钩子情况呢?

./bin/emqx eval "ets:lookup(emqx_hooks, 'client.check_acl')"


image

看这个配置是在系统内生效了的。

  1. 看看这个客户端保留会话的标志位是多少,./bin/emqx_ctl clients list|grep INT19001001

  2. 对这个 HTTP 服务抓包,例如 sudo tcpdump -i any port 8088 -vvn -w httpsvr.cap

那只有抓包看看了

httpsvr.zip (8.4 KB)

看你的抓包是没有请求的.这就比较奇怪了。可以尝试开下调式,我们看下是否有发起请求。

./bin/emqx eval 'dbg:tracer(),dbg:p(all,call),dbg:tp(emqx_acl_http, check_acl,x),dbg:tp(emqx_auth_http_cli,request,x).'

开启后,当发起发布或者订阅时,可以在 log/erlang.log.* 文件中看到调试输出。
可以把这个输出放到这里我看下结果呢