使用HTTP认证方式,客户端username和password置空时无法触发http认证请求

环境信息

  • EMQX 版本:5.0.3
  • 操作系统及版本:kubernetes v1.24.3+k3s1 on Ubuntu 20.04.4 LTS

问题描述

emqx后台开启HttpServer - Password based,并配置自己的认证http服务器。
发现客户端连接在username, password都为空时,无法触发http认证请求转发(自己的认证http服务器无请求日志)

配置文件及日志

使用hlemchart在k3s安装的emqx,安装yaml除replicaCount是2、service配置了nodeport映射基本没怎么改

2022-08-19T12:56:05.972339+00:00 [warning] authenticator: <<"password_based:http">>, clientid: prodtestclientid, exception: error, line: 660, mfa: emqx_authentication:do_authenticate/3, msg: unexpected_error_in_authentication, peername: 10.42.0.1:17252, reason: {cannot_get_variable,<<"password">>}, stacktrace: [{emqx_authn_utils,handle_var,2,[{file,"emqx_authn_utils.erl"},{line,207}]},{lists,map,2,[{file,"lists.erl"},{line,1243}]},{emqx_placeholder,proc_tmpl,3,[{file,"emqx_placeholder.erl"},{line,102}]},{emqx_placeholder,'-proc_tmpl_deep/3-fun-1-',3,[{file,"emqx_placeholder.erl"},{line,198}]},{lists,map,2,[{file,"lists.erl"},{line,1243}]},{lists,map,2,[{file,"lists.erl"},{line,1243}]},{emqx_placeholder,proc_tmpl_deep,3,[{file,"emqx_placeholder.erl"},{line,196}]},{emqx_authn_http,generate_request,2,[{file,"emqx_authn_http.erl"},{line,313}]},{emqx_authn_http,authenticate,2,[{file,"emqx_authn_http.erl"},{line,190}]},{emqx_authentication,do_authenticate,3,[{file,"emqx_authentication.erl"},{line,633}]},{emqx_authentication,authenticate,2,[{file,"emqx_authentication.erl"},{line,228}]},{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,authenticate,1,[{file,"emqx_access_control.erl"},{line,81}]},{emqx_channel,do_authenticate,2,[{file,"emqx_channel.erl"},{line,1697}]},{emqx_channel,handle_in,2,[{file,"emqx_channel.erl"},{line,355}]},{emqx_connection,with_channel,3,[{file,"emqx_connection.erl"},{line,801}]},{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}]}]

没有 Password 是没法通过认证

请问有没有方法可以绕过呢,有一批p和u为空客户端需要兼容。写插件可以吗?

mqtt版本使用3.1.1

插件可以的。不过要用 erlang,挂一个认证的钩子处理下就好了

感谢解惑