Merge pull request #9046 from HJianBo/more-logs-for-auth-http
More logs for http authn/authz
This commit is contained in:
commit
49a5862a63
|
@ -41,12 +41,18 @@ check_acl(#{username := <<$$, _/binary>>}, _PubSub, _Topic, _AclResult, _Params)
|
||||||
ok;
|
ok;
|
||||||
check_acl(ClientInfo, PubSub, Topic, _AclResult, #{acl := ACLParams = #{path := Path}}) ->
|
check_acl(ClientInfo, PubSub, Topic, _AclResult, #{acl := ACLParams = #{path := Path}}) ->
|
||||||
ClientInfo1 = ClientInfo#{access => access(PubSub), topic => Topic},
|
ClientInfo1 = ClientInfo#{access => access(PubSub), topic => Topic},
|
||||||
|
Username = maps:get(username, ClientInfo1, undefined),
|
||||||
case check_acl_request(ACLParams, ClientInfo1) of
|
case check_acl_request(ACLParams, ClientInfo1) of
|
||||||
{ok, 200, <<"ignore">>} -> ok;
|
{ok, 200, <<"ignore">>} -> ok;
|
||||||
{ok, 200, _Body} -> {stop, allow};
|
{ok, 200, _Body} -> {stop, allow};
|
||||||
{ok, _Code, _Body} -> {stop, deny};
|
{ok, Code, _Body} ->
|
||||||
{error, Error} ->
|
?LOG(error, "Deny ~s to topic ~ts, username: ~ts, http response code: ~p",
|
||||||
?LOG(error, "Request ACL path ~s, error: ~p", [Path, Error]),
|
[PubSub, Topic, Username, Code]),
|
||||||
|
{stop, deny};
|
||||||
|
{error, Error} ->
|
||||||
|
?LOG(error, "Deny ~s to topic ~ts, username: ~ts, due to request "
|
||||||
|
"http server failure, path: ~p, error: ~0p",
|
||||||
|
[PubSub, Topic, Username, Path, Error]),
|
||||||
ok
|
ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{application, emqx_auth_http,
|
{application, emqx_auth_http,
|
||||||
[{description, "EMQ X Authentication/ACL with HTTP API"},
|
[{description, "EMQ X Authentication/ACL with HTTP API"},
|
||||||
{vsn, "4.3.8"}, % strict semver, bump manually!
|
{vsn, "4.3.9"}, % strict semver, bump manually!
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{registered, [emqx_auth_http_sup]},
|
{registered, [emqx_auth_http_sup]},
|
||||||
{applications, [kernel,stdlib,ehttpc]},
|
{applications, [kernel,stdlib,ehttpc]},
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
%% -*- mode: erlang -*-
|
%% -*- mode: erlang -*-
|
||||||
%% Unless you know what you are doing, DO NOT edit manually!!
|
%% Unless you know what you are doing, DO NOT edit manually!!
|
||||||
{VSN,
|
{VSN,
|
||||||
[{"4.3.7",
|
[{"4.3.8",
|
||||||
|
[{load_module,emqx_auth_http,brutal_purge,soft_purge,[]},
|
||||||
|
{load_module,emqx_acl_http,brutal_purge,soft_purge,[]}]},
|
||||||
|
{"4.3.7",
|
||||||
[{load_module,emqx_auth_http_cli,brutal_purge,soft_purge,[]},
|
[{load_module,emqx_auth_http_cli,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_auth_http,brutal_purge,soft_purge,[]},
|
{load_module,emqx_auth_http,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_acl_http,brutal_purge,soft_purge,[]}]},
|
{load_module,emqx_acl_http,brutal_purge,soft_purge,[]}]},
|
||||||
|
@ -32,7 +35,10 @@
|
||||||
{load_module,emqx_auth_http_cli,brutal_purge,soft_purge,[]}]},
|
{load_module,emqx_auth_http_cli,brutal_purge,soft_purge,[]}]},
|
||||||
{<<"4.3.[0-1]">>,[{restart_application,emqx_auth_http}]},
|
{<<"4.3.[0-1]">>,[{restart_application,emqx_auth_http}]},
|
||||||
{<<".*">>,[]}],
|
{<<".*">>,[]}],
|
||||||
[{"4.3.7",
|
[{"4.3.8",
|
||||||
|
[{load_module,emqx_auth_http,brutal_purge,soft_purge,[]},
|
||||||
|
{load_module,emqx_acl_http,brutal_purge,soft_purge,[]}]},
|
||||||
|
{"4.3.7",
|
||||||
[{load_module,emqx_auth_http_cli,brutal_purge,soft_purge,[]},
|
[{load_module,emqx_auth_http_cli,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_auth_http,brutal_purge,soft_purge,[]},
|
{load_module,emqx_auth_http,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_acl_http,brutal_purge,soft_purge,[]}]},
|
{load_module,emqx_acl_http,brutal_purge,soft_purge,[]}]},
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
check(ClientInfo, AuthResult, #{auth := AuthParms = #{path := Path},
|
check(ClientInfo, AuthResult, #{auth := AuthParms = #{path := Path},
|
||||||
super := SuperParams}) ->
|
super := SuperParams}) ->
|
||||||
|
Username = maps:get(username, ClientInfo, undefined),
|
||||||
case authenticate(AuthParms, ClientInfo) of
|
case authenticate(AuthParms, ClientInfo) of
|
||||||
{ok, 200, <<"ignore">>} ->
|
{ok, 200, <<"ignore">>} ->
|
||||||
ok;
|
ok;
|
||||||
|
@ -46,12 +47,15 @@ check(ClientInfo, AuthResult, #{auth := AuthParms = #{path := Path},
|
||||||
anonymous => false,
|
anonymous => false,
|
||||||
mountpoint => mountpoint(Body, ClientInfo)}};
|
mountpoint => mountpoint(Body, ClientInfo)}};
|
||||||
{ok, Code, _Body} ->
|
{ok, Code, _Body} ->
|
||||||
?LOG(error, "Deny connection from path: ~s, response http code: ~p",
|
?LOG(error, "Deny connection from path: ~s, username: ~ts, http "
|
||||||
[Path, Code]),
|
"response code: ~p",
|
||||||
|
[Path, Username, Code]),
|
||||||
{stop, AuthResult#{auth_result => http_to_connack_error(Code),
|
{stop, AuthResult#{auth_result => http_to_connack_error(Code),
|
||||||
anonymous => false}};
|
anonymous => false}};
|
||||||
{error, Error} ->
|
{error, Error} ->
|
||||||
?LOG(error, "Request auth path: ~s, error: ~p", [Path, Error]),
|
?LOG(error, "Deny connection from path: ~s, username: ~ts, due to "
|
||||||
|
"request http-server failed: ~0p",
|
||||||
|
[Path, Username, Error]),
|
||||||
%%FIXME later: server_unavailable is not right.
|
%%FIXME later: server_unavailable is not right.
|
||||||
{stop, AuthResult#{auth_result => server_unavailable,
|
{stop, AuthResult#{auth_result => server_unavailable,
|
||||||
anonymous => false}}
|
anonymous => false}}
|
||||||
|
|
Loading…
Reference in New Issue