|
@@ -319,7 +319,7 @@ authorize(
|
|
|
is_superuser => true
|
|
is_superuser => true
|
|
|
}),
|
|
}),
|
|
|
emqx_metrics:inc(?METRIC_SUPERUSER),
|
|
emqx_metrics:inc(?METRIC_SUPERUSER),
|
|
|
- {stop, allow};
|
|
|
|
|
|
|
+ {stop, #{result => allow, from => superuser}};
|
|
|
false ->
|
|
false ->
|
|
|
authorize_non_superuser(Client, PubSub, Topic, DefaultResult, Sources)
|
|
authorize_non_superuser(Client, PubSub, Topic, DefaultResult, Sources)
|
|
|
end.
|
|
end.
|
|
@@ -331,15 +331,11 @@ authorize_non_superuser(
|
|
|
} = Client,
|
|
} = Client,
|
|
|
PubSub,
|
|
PubSub,
|
|
|
Topic,
|
|
Topic,
|
|
|
- DefaultResult,
|
|
|
|
|
|
|
+ _DefaultResult,
|
|
|
Sources
|
|
Sources
|
|
|
) ->
|
|
) ->
|
|
|
case do_authorize(Client, PubSub, Topic, sources_with_defaults(Sources)) of
|
|
case do_authorize(Client, PubSub, Topic, sources_with_defaults(Sources)) of
|
|
|
{{matched, allow}, AuthzSource} ->
|
|
{{matched, allow}, AuthzSource} ->
|
|
|
- emqx:run_hook(
|
|
|
|
|
- 'client.check_authz_complete',
|
|
|
|
|
- [Client, PubSub, Topic, allow, AuthzSource]
|
|
|
|
|
- ),
|
|
|
|
|
log_allowed(#{
|
|
log_allowed(#{
|
|
|
username => Username,
|
|
username => Username,
|
|
|
ipaddr => IpAddress,
|
|
ipaddr => IpAddress,
|
|
@@ -348,12 +344,8 @@ authorize_non_superuser(
|
|
|
}),
|
|
}),
|
|
|
emqx_metrics_worker:inc(authz_metrics, AuthzSource, allow),
|
|
emqx_metrics_worker:inc(authz_metrics, AuthzSource, allow),
|
|
|
emqx_metrics:inc(?METRIC_ALLOW),
|
|
emqx_metrics:inc(?METRIC_ALLOW),
|
|
|
- {stop, allow};
|
|
|
|
|
|
|
+ {stop, #{result => allow, from => AuthzSource}};
|
|
|
{{matched, deny}, AuthzSource} ->
|
|
{{matched, deny}, AuthzSource} ->
|
|
|
- emqx:run_hook(
|
|
|
|
|
- 'client.check_authz_complete',
|
|
|
|
|
- [Client, PubSub, Topic, deny, AuthzSource]
|
|
|
|
|
- ),
|
|
|
|
|
?SLOG(warning, #{
|
|
?SLOG(warning, #{
|
|
|
msg => "authorization_permission_denied",
|
|
msg => "authorization_permission_denied",
|
|
|
username => Username,
|
|
username => Username,
|
|
@@ -363,12 +355,8 @@ authorize_non_superuser(
|
|
|
}),
|
|
}),
|
|
|
emqx_metrics_worker:inc(authz_metrics, AuthzSource, deny),
|
|
emqx_metrics_worker:inc(authz_metrics, AuthzSource, deny),
|
|
|
emqx_metrics:inc(?METRIC_DENY),
|
|
emqx_metrics:inc(?METRIC_DENY),
|
|
|
- {stop, deny};
|
|
|
|
|
|
|
+ {stop, #{result => deny, from => AuthzSource}};
|
|
|
nomatch ->
|
|
nomatch ->
|
|
|
- emqx:run_hook(
|
|
|
|
|
- 'client.check_authz_complete',
|
|
|
|
|
- [Client, PubSub, Topic, DefaultResult, default]
|
|
|
|
|
- ),
|
|
|
|
|
?SLOG(info, #{
|
|
?SLOG(info, #{
|
|
|
msg => "authorization_failed_nomatch",
|
|
msg => "authorization_failed_nomatch",
|
|
|
username => Username,
|
|
username => Username,
|
|
@@ -377,7 +365,7 @@ authorize_non_superuser(
|
|
|
reason => "no-match rule"
|
|
reason => "no-match rule"
|
|
|
}),
|
|
}),
|
|
|
emqx_metrics:inc(?METRIC_NOMATCH),
|
|
emqx_metrics:inc(?METRIC_NOMATCH),
|
|
|
- {stop, DefaultResult}
|
|
|
|
|
|
|
+ ignore
|
|
|
end.
|
|
end.
|
|
|
|
|
|
|
|
log_allowed(Meta) ->
|
|
log_allowed(Meta) ->
|