chore(emqx authz): rename root name for authz conf
Signed-off-by: zhanghongtong <rory-z@outlook.com>
This commit is contained in:
parent
4ef00072b9
commit
4c6739161d
|
@ -244,7 +244,7 @@ fields("auth") ->
|
|||
[ {"enable", t(boolean(), undefined, false)}
|
||||
];
|
||||
|
||||
fields("authorization") ->
|
||||
fields("authorization_settings") ->
|
||||
[ {"enable", t(boolean(), undefined, true)}
|
||||
, {"cache", ref("authorization_cache")}
|
||||
, {"deny_action", t(union(ignore, disconnect), undefined, ignore)}
|
||||
|
@ -293,7 +293,7 @@ fields("zones") ->
|
|||
|
||||
fields("zone_settings") ->
|
||||
[ {"mqtt", ref("mqtt")}
|
||||
, {"authorization", ref("authorization")}
|
||||
, {"authorization", ref("authorization_settings")}
|
||||
, {"auth", ref("auth")}
|
||||
, {"stats", ref("stats")}
|
||||
, {"flapping_detect", ref("flapping_detect")}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
emqx_authz:{
|
||||
authorization:{
|
||||
rules: [
|
||||
# {
|
||||
# type: http
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
-export([post_config_update/2, pre_config_update/2]).
|
||||
|
||||
-define(CONF_KEY_PATH, [emqx_authz, rules]).
|
||||
-define(CONF_KEY_PATH, [authorization, rules]).
|
||||
|
||||
-spec(register_metrics() -> ok).
|
||||
register_metrics() ->
|
||||
|
|
|
@ -47,8 +47,8 @@ parse_query(Sql) ->
|
|||
|
||||
authorize(Client, PubSub, Topic,
|
||||
#{annotations := #{id := ResourceID,
|
||||
sql := {SQL, Params}
|
||||
}
|
||||
sql := {SQL, Params}
|
||||
}
|
||||
}) ->
|
||||
case emqx_resource:query(ResourceID, {sql, SQL, replvar(Params, Client)}) of
|
||||
{ok, _Columns, []} -> nomatch;
|
||||
|
|
|
@ -51,8 +51,8 @@ parse_query(Sql) ->
|
|||
|
||||
authorize(Client, PubSub, Topic,
|
||||
#{annotations := #{id := ResourceID,
|
||||
sql := {SQL, Params}
|
||||
}
|
||||
sql := {SQL, Params}
|
||||
}
|
||||
}) ->
|
||||
case emqx_resource:query(ResourceID, {sql, SQL, replvar(Params, Client)}) of
|
||||
{ok, _Columns, []} -> nomatch;
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
, fields/1
|
||||
]).
|
||||
|
||||
structs() -> ["emqx_authz"].
|
||||
structs() -> ["authorization"].
|
||||
|
||||
fields("emqx_authz") ->
|
||||
fields("authorization") ->
|
||||
[ {rules, rules()}
|
||||
];
|
||||
fields(http) ->
|
||||
|
|
|
@ -43,12 +43,12 @@ groups() ->
|
|||
[].
|
||||
|
||||
init_per_suite(Config) ->
|
||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||
%% important! let emqx_schema include the current app!
|
||||
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_schema, includes, fun() -> ["emqx_authz"] end ),
|
||||
meck:expect(emqx_schema, includes, fun() -> ["authorization"] end ),
|
||||
meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
|
||||
|
||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||
%create_default_app(),
|
||||
Config.
|
||||
|
||||
|
@ -92,7 +92,7 @@ t_api_unit_test(_Config) ->
|
|||
principal :=
|
||||
#{'and' := [#{username := <<"^test?">>},
|
||||
#{clientid := <<"^test?">>}]},
|
||||
topics := [<<"%u">>]}] = emqx_config:get([emqx_authz, rules]).
|
||||
topics := [<<"%u">>]}] = emqx_config:get([authorization, rules]).
|
||||
|
||||
% t_api(_Config) ->
|
||||
% Rule1 = #{<<"principal">> =>
|
||||
|
|
|
@ -29,14 +29,16 @@ groups() ->
|
|||
[].
|
||||
|
||||
init_per_suite(Config) ->
|
||||
%% important! let emqx_schema include the current app!
|
||||
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_schema, includes, fun() -> ["emqx_authz"] end ),
|
||||
meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
|
||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||
|
||||
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
|
||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||
|
||||
%% important! let emqx_schema include the current app!
|
||||
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_schema, includes, fun() -> ["authorization"] end ),
|
||||
meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
|
||||
|
||||
ok = emqx_config:update([zones, default, authorization, cache, enable], false),
|
||||
ok = emqx_config:update([zones, default, authorization, enable], true),
|
||||
Rules = [#{ <<"config">> => #{
|
||||
|
|
|
@ -29,16 +29,16 @@ groups() ->
|
|||
[].
|
||||
|
||||
init_per_suite(Config) ->
|
||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||
|
||||
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
|
||||
|
||||
%% important! let emqx_schema include the current app!
|
||||
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_schema, includes, fun() -> ["emqx_authz"] end ),
|
||||
meck:expect(emqx_schema, includes, fun() -> ["authorization"] end ),
|
||||
meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
|
||||
|
||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||
ct:pal("---- emqx_hooks: ~p", [ets:tab2list(emqx_hooks)]),
|
||||
ok = emqx_config:update([zones, default, authorization, cache, enable], false),
|
||||
ok = emqx_config:update([zones, default, authorization, enable], true),
|
||||
Rules = [#{ <<"config">> => #{
|
||||
|
|
|
@ -29,14 +29,16 @@ groups() ->
|
|||
[].
|
||||
|
||||
init_per_suite(Config) ->
|
||||
%% important! let emqx_schema include the current app!
|
||||
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_schema, includes, fun() -> ["emqx_authz"] end ),
|
||||
meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
|
||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||
|
||||
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
|
||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||
|
||||
%% important! let emqx_schema include the current app!
|
||||
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_schema, includes, fun() -> ["authorization"] end ),
|
||||
meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
|
||||
|
||||
ok = emqx_config:update([zones, default, authorization, cache, enable], false),
|
||||
ok = emqx_config:update([zones, default, authorization, enable], true),
|
||||
Rules = [#{ <<"config">> => #{
|
||||
|
|
|
@ -29,14 +29,16 @@ groups() ->
|
|||
[].
|
||||
|
||||
init_per_suite(Config) ->
|
||||
%% important! let emqx_schema include the current app!
|
||||
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_schema, includes, fun() -> ["emqx_authz"] end ),
|
||||
meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
|
||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||
|
||||
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
|
||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||
|
||||
%% important! let emqx_schema include the current app!
|
||||
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_schema, includes, fun() -> ["authorization"] end ),
|
||||
meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
|
||||
|
||||
ok = emqx_config:update([zones, default, authorization, cache, enable], false),
|
||||
ok = emqx_config:update([zones, default, authorization, enable], true),
|
||||
Rules = [#{ <<"config">> => #{
|
||||
|
|
|
@ -29,14 +29,16 @@ groups() ->
|
|||
[].
|
||||
|
||||
init_per_suite(Config) ->
|
||||
%% important! let emqx_schema include the current app!
|
||||
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_schema, includes, fun() -> ["emqx_authz"] end ),
|
||||
meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
|
||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||
|
||||
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
|
||||
ok = emqx_ct_helpers:start_apps([emqx_authz]),
|
||||
|
||||
%% important! let emqx_schema include the current app!
|
||||
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
|
||||
meck:expect(emqx_schema, includes, fun() -> ["authorization"] end ),
|
||||
meck:expect(emqx_schema, extra_schema_fields, fun(FieldName) -> emqx_authz_schema:fields(FieldName) end),
|
||||
|
||||
ok = emqx_config:update([zones, default, authorization, cache, enable], false),
|
||||
ok = emqx_config:update([zones, default, authorization, enable], true),
|
||||
Rules = [#{ <<"config">> => #{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
[ {"emqx_data_bridge", emqx_data_bridge_schema}
|
||||
, {"emqx_retainer", emqx_retainer_schema}
|
||||
, {"emqx_authn", emqx_authn_schema}
|
||||
, {"emqx_authz", emqx_authz_schema}
|
||||
, {"authorization", emqx_authz_schema}
|
||||
, {"emqx_bridge_mqtt", emqx_bridge_mqtt_schema}
|
||||
, {"emqx_modules", emqx_modules_schema}
|
||||
, {"emqx_management", emqx_management_schema}
|
||||
|
|
Loading…
Reference in New Issue