Merge pull request #10665 from zhongwencool/fix-authn-init-empty
fix: authn init is empty
This commit is contained in:
commit
f2e01b8fc4
|
@ -72,7 +72,7 @@ chain_configs() ->
|
|||
[global_chain_config() | listener_chain_configs()].
|
||||
|
||||
global_chain_config() ->
|
||||
{?GLOBAL, emqx:get_config([?EMQX_AUTHENTICATION_CONFIG_ROOT_NAME_BINARY], [])}.
|
||||
{?GLOBAL, emqx:get_config([?EMQX_AUTHENTICATION_CONFIG_ROOT_NAME_ATOM], [])}.
|
||||
|
||||
listener_chain_configs() ->
|
||||
lists:map(
|
||||
|
@ -83,9 +83,11 @@ listener_chain_configs() ->
|
|||
).
|
||||
|
||||
auth_config_path(ListenerID) ->
|
||||
[<<"listeners">>] ++
|
||||
binary:split(atom_to_binary(ListenerID), <<":">>) ++
|
||||
[?EMQX_AUTHENTICATION_CONFIG_ROOT_NAME_BINARY].
|
||||
Names = [
|
||||
binary_to_existing_atom(N, utf8)
|
||||
|| N <- binary:split(atom_to_binary(ListenerID), <<":">>)
|
||||
],
|
||||
[listeners] ++ Names ++ [?EMQX_AUTHENTICATION_CONFIG_ROOT_NAME_ATOM].
|
||||
|
||||
provider_types() ->
|
||||
lists:map(fun({Type, _Module}) -> Type end, emqx_authn:providers()).
|
||||
|
|
|
@ -54,13 +54,14 @@
|
|||
|
||||
-define(BRIDGE_NOT_FOUND(BRIDGE_TYPE, BRIDGE_NAME),
|
||||
?NOT_FOUND(
|
||||
<<"Bridge lookup failed: bridge named '", (BRIDGE_NAME)/binary, "' of type ",
|
||||
<<"Bridge lookup failed: bridge named '", (bin(BRIDGE_NAME))/binary, "' of type ",
|
||||
(bin(BRIDGE_TYPE))/binary, " does not exist.">>
|
||||
)
|
||||
).
|
||||
|
||||
%% Don't turn bridge_name to atom, it's maybe not a existing atom.
|
||||
-define(TRY_PARSE_ID(ID, EXPR),
|
||||
try emqx_bridge_resource:parse_bridge_id(Id) of
|
||||
try emqx_bridge_resource:parse_bridge_id(Id, #{atom_name => false}) of
|
||||
{BridgeType, BridgeName} ->
|
||||
EXPR
|
||||
catch
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
resource_id/2,
|
||||
bridge_id/2,
|
||||
parse_bridge_id/1,
|
||||
parse_bridge_id/2,
|
||||
bridge_hookpoint/1,
|
||||
bridge_hookpoint_to_bridge_id/1
|
||||
]).
|
||||
|
@ -86,11 +87,15 @@ bridge_id(BridgeType, BridgeName) ->
|
|||
Type = bin(BridgeType),
|
||||
<<Type/binary, ":", Name/binary>>.
|
||||
|
||||
-spec parse_bridge_id(list() | binary() | atom()) -> {atom(), binary()}.
|
||||
parse_bridge_id(BridgeId) ->
|
||||
parse_bridge_id(BridgeId, #{atom_name => true}).
|
||||
|
||||
-spec parse_bridge_id(list() | binary() | atom(), #{atom_name => boolean()}) ->
|
||||
{atom(), atom() | binary()}.
|
||||
parse_bridge_id(BridgeId, Opts) ->
|
||||
case string:split(bin(BridgeId), ":", all) of
|
||||
[Type, Name] ->
|
||||
{to_type_atom(Type), validate_name(Name)};
|
||||
{to_type_atom(Type), validate_name(Name, Opts)};
|
||||
_ ->
|
||||
invalid_data(
|
||||
<<"should be of pattern {type}:{name}, but got ", BridgeId/binary>>
|
||||
|
@ -105,13 +110,16 @@ bridge_hookpoint_to_bridge_id(?BRIDGE_HOOKPOINT(BridgeId)) ->
|
|||
bridge_hookpoint_to_bridge_id(_) ->
|
||||
{error, bad_bridge_hookpoint}.
|
||||
|
||||
validate_name(Name0) ->
|
||||
validate_name(Name0, Opts) ->
|
||||
Name = unicode:characters_to_list(Name0, utf8),
|
||||
case is_list(Name) andalso Name =/= [] of
|
||||
true ->
|
||||
case lists:all(fun is_id_char/1, Name) of
|
||||
true ->
|
||||
Name0;
|
||||
case maps:get(atom_name, Opts, true) of
|
||||
true -> list_to_existing_atom(Name);
|
||||
false -> Name0
|
||||
end;
|
||||
false ->
|
||||
invalid_data(<<"bad name: ", Name0/binary>>)
|
||||
end;
|
||||
|
|
|
@ -583,7 +583,7 @@ config(Args0, More) ->
|
|||
ct:pal("Running tests with conf:\n~p", [Conf]),
|
||||
InstId = maps:get("instance_id", Args),
|
||||
<<"bridge:", BridgeId/binary>> = InstId,
|
||||
{Type, Name} = emqx_bridge_resource:parse_bridge_id(BridgeId),
|
||||
{Type, Name} = emqx_bridge_resource:parse_bridge_id(BridgeId, #{atom_name => false}),
|
||||
TypeBin = atom_to_binary(Type),
|
||||
hocon_tconf:check_plain(
|
||||
emqx_bridge_schema,
|
||||
|
@ -596,7 +596,7 @@ config(Args0, More) ->
|
|||
hocon_config(Args) ->
|
||||
InstId = maps:get("instance_id", Args),
|
||||
<<"bridge:", BridgeId/binary>> = InstId,
|
||||
{_Type, Name} = emqx_bridge_resource:parse_bridge_id(BridgeId),
|
||||
{_Type, Name} = emqx_bridge_resource:parse_bridge_id(BridgeId, #{atom_name => false}),
|
||||
AuthConf = maps:get("authentication", Args),
|
||||
AuthTemplate = iolist_to_binary(hocon_config_template_authentication(AuthConf)),
|
||||
AuthConfRendered = bbmustache:render(AuthTemplate, AuthConf),
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
{application, emqx_rule_engine, [
|
||||
{description, "EMQX Rule Engine"},
|
||||
% strict semver, bump manually!
|
||||
{vsn, "5.0.15"},
|
||||
{vsn, "5.0.16"},
|
||||
{modules, []},
|
||||
{registered, [emqx_rule_engine_sup, emqx_rule_engine]},
|
||||
{applications, [kernel, stdlib, rulesql, getopt, emqx_ctl]},
|
||||
|
|
|
@ -341,7 +341,10 @@ get_basic_usage_info() ->
|
|||
tally_referenced_bridges(BridgeIDs, Acc0) ->
|
||||
lists:foldl(
|
||||
fun(BridgeID, Acc) ->
|
||||
{BridgeType, _BridgeName} = emqx_bridge_resource:parse_bridge_id(BridgeID),
|
||||
{BridgeType, _BridgeName} = emqx_bridge_resource:parse_bridge_id(
|
||||
BridgeID,
|
||||
#{atom_name => false}
|
||||
),
|
||||
maps:update_with(
|
||||
BridgeType,
|
||||
fun(X) -> X + 1 end,
|
||||
|
|
Loading…
Reference in New Issue