Merge pull request #11336 from savonarola/0724-trace-authz

Trace non-resultative authz calls
This commit is contained in:
Ilya Averyanov 2023-10-12 14:51:15 +03:00 committed by GitHub
commit 08795f559c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 1 deletions

View File

@ -498,7 +498,10 @@ do_authorize(_Client, _PubSub, _Topic, []) ->
do_authorize(Client, PubSub, Topic, [#{enable := false} | Rest]) ->
do_authorize(Client, PubSub, Topic, Rest);
do_authorize(
Client,
#{
username := Username,
peerhost := IpAddress
} = Client,
PubSub,
Topic,
[Connector = #{type := Type} | Tail]
@ -508,11 +511,32 @@ do_authorize(
try Module:authorize(Client, PubSub, Topic, Connector) of
nomatch ->
emqx_metrics_worker:inc(authz_metrics, Type, nomatch),
?TRACE("AUTHZ", "authorization_module_nomatch", #{
module => Module,
username => Username,
ipaddr => IpAddress,
topic => Topic,
pub_sub => PubSub
}),
do_authorize(Client, PubSub, Topic, Tail);
%% {matched, allow | deny | ignore}
{matched, ignore} ->
?TRACE("AUTHZ", "authorization_module_match_ignore", #{
module => Module,
username => Username,
ipaddr => IpAddress,
topic => Topic,
pub_sub => PubSub
}),
do_authorize(Client, PubSub, Topic, Tail);
ignore ->
?TRACE("AUTHZ", "authorization_module_ignore", #{
module => Module,
username => Username,
ipaddr => IpAddress,
topic => Topic,
pub_sub => PubSub
}),
do_authorize(Client, PubSub, Topic, Tail);
%% {matched, allow | deny}
Matched ->