chore(authz): rename ACL to AuthZ

This commit is contained in:
Rory Z 2021-07-05 15:11:58 +08:00 committed by turtleDeng
parent f733293a8b
commit 45ee504dc5
7 changed files with 16 additions and 16 deletions

View File

@ -131,7 +131,7 @@ Sample data in the default configuration:
HSET mqtt_acl:emqx '$SYS/#' subscribe HSET mqtt_acl:emqx '$SYS/#' subscribe
``` ```
A rule of Redis ACL defines `publish`, `subscribe`, or `all `information. All lists in the rule are **allow** lists. A rule of Redis AuthZ defines `publish`, `subscribe`, or `all `information. All lists in the rule are **allow** lists.
#### Mongo #### Mongo

View File

@ -6,14 +6,14 @@
-define(ALLOW_DENY(A), ((A =:= allow) orelse (A =:= deny))). -define(ALLOW_DENY(A), ((A =:= allow) orelse (A =:= deny))).
-define(PUBSUB(A), ((A =:= subscribe) orelse (A =:= publish) orelse (A =:= all))). -define(PUBSUB(A), ((A =:= subscribe) orelse (A =:= publish) orelse (A =:= all))).
-record(acl_metrics, { -record(authz_metrics, {
allow = 'client.acl.allow', allow = 'client.authorize.allow',
deny = 'client.acl.deny', deny = 'client.authorize.deny',
ignore = 'client.acl.ignore' ignore = 'client.authorize.ignore'
}). }).
-define(METRICS(Type), tl(tuple_to_list(#Type{}))). -define(METRICS(Type), tl(tuple_to_list(#Type{}))).
-define(METRICS(Type, K), #Type{}#Type.K). -define(METRICS(Type, K), #Type{}#Type.K).
-define(ACL_METRICS, ?METRICS(acl_metrics)). -define(AUTHZ_METRICS, ?METRICS(authz_metrics)).
-define(ACL_METRICS(K), ?METRICS(acl_metrics, K)). -define(AUTHZ_METRICS(K), ?METRICS(authz_metrics, K)).

View File

@ -32,7 +32,7 @@
-spec(register_metrics() -> ok). -spec(register_metrics() -> ok).
register_metrics() -> register_metrics() ->
lists:foreach(fun emqx_metrics:ensure/1, ?ACL_METRICS). lists:foreach(fun emqx_metrics:ensure/1, ?AUTHZ_METRICS).
init() -> init() ->
ok = register_metrics(), ok = register_metrics(),
@ -147,10 +147,10 @@ b2l(B) when is_list(B) -> B;
b2l(B) when is_binary(B) -> binary_to_list(B). b2l(B) when is_binary(B) -> binary_to_list(B).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% ACL callbacks %% AuthZ callbacks
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% @doc Check ACL %% @doc Check AuthZ
-spec(authorize(emqx_types:clientinfo(), emqx_types:all(), emqx_topic:topic(), emqx_permission_rule:acl_result(), rules()) -spec(authorize(emqx_types:clientinfo(), emqx_types:all(), emqx_topic:topic(), emqx_permission_rule:acl_result(), rules())
-> {stop, allow} | {ok, deny}). -> {stop, allow} | {ok, deny}).
authorize(#{username := Username, authorize(#{username := Username,
@ -159,11 +159,11 @@ authorize(#{username := Username,
case do_authorize(Client, PubSub, Topic, Rules) of case do_authorize(Client, PubSub, Topic, Rules) of
{matched, allow} -> {matched, allow} ->
?LOG(info, "Client succeeded authorization: Username: ~p, IP: ~p, Topic: ~p, Permission: allow", [Username, IpAddress, Topic]), ?LOG(info, "Client succeeded authorization: Username: ~p, IP: ~p, Topic: ~p, Permission: allow", [Username, IpAddress, Topic]),
emqx_metrics:inc(?ACL_METRICS(allow)), emqx_metrics:inc(?AUTHZ_METRICS(allow)),
{stop, allow}; {stop, allow};
{matched, deny} -> {matched, deny} ->
?LOG(info, "Client failed authorization: Username: ~p, IP: ~p, Topic: ~p, Permission: deny", [Username, IpAddress, Topic]), ?LOG(info, "Client failed authorization: Username: ~p, IP: ~p, Topic: ~p, Permission: deny", [Username, IpAddress, Topic]),
emqx_metrics:inc(?ACL_METRICS(deny)), emqx_metrics:inc(?AUTHZ_METRICS(deny)),
{stop, deny}; {stop, deny};
nomatch -> nomatch ->
?LOG(info, "Client failed authorization: Username: ~p, IP: ~p, Topic: ~p, Reasion: ~p", [Username, IpAddress, Topic, "no-match rule"]), ?LOG(info, "Client failed authorization: Username: ~p, IP: ~p, Topic: ~p, Reasion: ~p", [Username, IpAddress, Topic, "no-match rule"]),

View File

@ -20,7 +20,7 @@
-include_lib("emqx/include/emqx.hrl"). -include_lib("emqx/include/emqx.hrl").
-include_lib("emqx/include/logger.hrl"). -include_lib("emqx/include/logger.hrl").
%% ACL Callbacks %% AuthZ Callbacks
-export([ authorize/4 -export([ authorize/4
, description/0 , description/0
]). ]).

View File

@ -20,7 +20,7 @@
-include_lib("emqx/include/emqx.hrl"). -include_lib("emqx/include/emqx.hrl").
-include_lib("emqx/include/logger.hrl"). -include_lib("emqx/include/logger.hrl").
%% ACL Callbacks %% AuthZ Callbacks
-export([ description/0 -export([ description/0
, parse_query/1 , parse_query/1
, authorize/4 , authorize/4

View File

@ -20,7 +20,7 @@
-include_lib("emqx/include/emqx.hrl"). -include_lib("emqx/include/emqx.hrl").
-include_lib("emqx/include/logger.hrl"). -include_lib("emqx/include/logger.hrl").
%% ACL Callbacks %% AuthZ Callbacks
-export([ description/0 -export([ description/0
, parse_query/1 , parse_query/1
, authorize/4 , authorize/4

View File

@ -20,7 +20,7 @@
-include_lib("emqx/include/emqx.hrl"). -include_lib("emqx/include/emqx.hrl").
-include_lib("emqx/include/logger.hrl"). -include_lib("emqx/include/logger.hrl").
%% ACL Callbacks %% AuthZ Callbacks
-export([ authorize/4 -export([ authorize/4
, description/0 , description/0
]). ]).