EMQX授权

错误报告

2023-02-16T08:11:47+00:00 [QUERY] mqttx_96c70fbd@172.18.88.1:61461 msg: redis_connector_received, connector: emqx_authz_redis:43, sql: HGETALLmqtt_acl:17328702195, state: [auto_reconnect: true, poolname: emqx_authz_redis:43:403, type: single]

2023-02-16T16:09:52.945362+00:00 [warning] authorize_type: redis, clientid: mqttx_96c70fbd, exception: error, line: 402, mfa: emqx_authz:do_authorize/4, msg: unexpected_error_in_authorize, peername: 172.18.88.1:61461, reason: function_clause, stacktrace: [{emqx_authz_rule,compile,[{allow,all,<<“Publish”>>,[<<“vanhitech/down/scene/32C42EAB874D”>>]}],[{file,“emqx_authz_rule.erl”},{line,61}]},{emqx_authz_redis,do_authorize,4,[{file,“emqx_authz_redis.erl”},{line,104}]},{emqx_authz,do_authorize,4,[{file,“emqx_authz.erl”},{line,387}]},{emqx_authz,authorize_non_superuser,5,[{file,“emqx_authz.erl”},{line,338}]},{emqx_hooks,safe_execute,2,[{file,“emqx_hooks.erl”},{line,200}]},{emqx_hooks,do_run_fold,3,[{file,“emqx_hooks.erl”},{line,180}]},{emqx_access_control,do_authorize,3,[{file,“emqx_access_control.erl”},{line,128}]},{emqx_access_control,check_authorization_cache,3,[{file,“emqx_access_control.erl”},{line,89}]},{emqx_access_control,authorize,3,[{file,“emqx_access_control.erl”},{line,80}]},{emqx_channel,check_pub_authz,2,[{file,“emqx_channel.erl”},{line,1851}]},{emqx_misc,pipeline,3,[{file,“emqx_misc.erl”},{line,159}]},{emqx_channel,process_publish,2,[{file,“emqx_channel.erl”},{line,641}]},{emqx_connection,with_channel,3,[{file,“emqx_connection.erl”},{line,790}]},{emqx_connection,process_msg,2,[{file,“emqx_connection.erl”},{line,466}]},{emqx_connection,process_msg,2,[{file,“emqx_connection.erl”},{line,472}]},{emqx_connection,handle_recv,3,[{file,“emqx_connection.erl”},{line,428}]},{proc_lib,wake_up,3,[{file,“proc_lib.erl”},{line,236}]}]

环境

  • EMQX 版本:5.0
  • 操作系统版本:win10

预期行为

我只给了主题:vanhitech/down/online/32C42EAB874D授予subscribe权限,它应该不能发布消息

实际行为

实际是主题:vanhitech/down/online/32C42EAB874D把消息发布了

2023-02-16T08:11:47+00:00 [PUBLISH] mqttx_96c70fbd@172.18.88.1:61461 msg: publish_to, topic: vanhitech/down/online/32C42EAB874D, payload: {
“clientToken”:“clientToken-1670323948669”,
“method”:“report_add”
}

2023-02-16T08:11:47+00:00 [MQTT] mqttx_96c70fbd@172.18.88.1:61461 msg: mqtt_packet_sent, packet: PUBLISH(Q0, R0, D0),Topic=vanhitech/down/online/32C42EAB874D, PacketId=undefinedPayload={
“clientToken”:“clientToken-1670323948669”,
“method”:“report_add”
}

看起来是你 Redis 里面的规则写错了,应该是 publish 而不是 Publish

没有啊,这个主题的规则是subscribe

我没给 publish 也能发布出去

方便提供一下 EMQX 和 Redis 的详细版本吗?看错误日志的话 EMQX 读取到的是 Publish 而不是 publish

EMQX 5.0.1 ,Redis 3.2.100

方便的话升级到最新的5.0.17试试,相对稳定很多