Merge pull request #5386 from tigercl/chore/authn-rename

chore(authn rename): rename emqx_authn to authentication
This commit is contained in:
tigercl 2021-08-03 09:43:51 +08:00 committed by GitHub
commit ccf9dd18fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 10 deletions

View File

@ -1,4 +1,4 @@
emqx_authn: { authentication: {
enable: false enable: false
authenticators: [ authenticators: [
# { # {

View File

@ -1158,12 +1158,12 @@ authentication(post, Request) ->
authenticators(post, Request) -> authenticators(post, Request) ->
{ok, Body, _} = cowboy_req:read_body(Request), {ok, Body, _} = cowboy_req:read_body(Request),
AuthenticatorConfig = emqx_json:decode(Body, [return_maps]), AuthenticatorConfig = emqx_json:decode(Body, [return_maps]),
Config = #{<<"emqx_authn">> => #{ Config = #{<<"authentication">> => #{
<<"authenticators">> => [AuthenticatorConfig] <<"authenticators">> => [AuthenticatorConfig]
}}, }},
NConfig = hocon_schema:check_plain(emqx_authn_schema, Config, NConfig = hocon_schema:check_plain(emqx_authn_schema, Config,
#{nullable => true}), #{nullable => true}),
#{emqx_authn := #{authenticators := [NAuthenticatorConfig]}} = emqx_map_lib:unsafe_atom_key_map(NConfig), #{authentication := #{authenticators := [NAuthenticatorConfig]}} = emqx_map_lib:unsafe_atom_key_map(NConfig),
case emqx_authn:create_authenticator(?CHAIN, NAuthenticatorConfig) of case emqx_authn:create_authenticator(?CHAIN, NAuthenticatorConfig) of
{ok, Authenticator2} -> {ok, Authenticator2} ->
{201, Authenticator2}; {201, Authenticator2};
@ -1186,12 +1186,12 @@ authenticators2(put, Request) ->
AuthenticatorID = cowboy_req:binding(id, Request), AuthenticatorID = cowboy_req:binding(id, Request),
{ok, Body, _} = cowboy_req:read_body(Request), {ok, Body, _} = cowboy_req:read_body(Request),
AuthenticatorConfig = emqx_json:decode(Body, [return_maps]), AuthenticatorConfig = emqx_json:decode(Body, [return_maps]),
Config = #{<<"emqx_authn">> => #{ Config = #{<<"authentication">> => #{
<<"authenticators">> => [AuthenticatorConfig] <<"authenticators">> => [AuthenticatorConfig]
}}, }},
NConfig = hocon_schema:check_plain(emqx_authn_schema, Config, NConfig = hocon_schema:check_plain(emqx_authn_schema, Config,
#{nullable => true}), #{nullable => true}),
#{emqx_authn := #{authenticators := [NAuthenticatorConfig]}} = emqx_map_lib:unsafe_atom_key_map(NConfig), #{authentication := #{authenticators := [NAuthenticatorConfig]}} = emqx_map_lib:unsafe_atom_key_map(NConfig),
case emqx_authn:update_or_create_authenticator(?CHAIN, AuthenticatorID, NAuthenticatorConfig) of case emqx_authn:update_or_create_authenticator(?CHAIN, AuthenticatorID, NAuthenticatorConfig) of
{ok, Authenticator} -> {ok, Authenticator} ->
{200, Authenticator}; {200, Authenticator};

View File

@ -36,8 +36,8 @@ stop(_State) ->
ok. ok.
initialize() -> initialize() ->
AuthNConfig = emqx_config:get([emqx_authn], #{enable => false, AuthNConfig = emqx_config:get([authentication], #{enable => false,
authenticators => []}), authenticators => []}),
initialize(AuthNConfig). initialize(AuthNConfig).
initialize(#{enable := Enable, authenticators := AuthenticatorsConfig}) -> initialize(#{enable := Enable, authenticators := AuthenticatorsConfig}) ->

View File

@ -28,9 +28,9 @@
-export([ authenticator_name/1 -export([ authenticator_name/1
]). ]).
structs() -> [ "emqx_authn" ]. structs() -> [ "authentication" ].
fields("emqx_authn") -> fields("authentication") ->
[ {enable, fun enable/1} [ {enable, fun enable/1}
, {authenticators, fun authenticators/1} , {authenticators, fun authenticators/1}
]. ].

View File

@ -5,7 +5,7 @@
%% %%
[ {"emqx_data_bridge", emqx_data_bridge_schema} [ {"emqx_data_bridge", emqx_data_bridge_schema}
, {"emqx_retainer", emqx_retainer_schema} , {"emqx_retainer", emqx_retainer_schema}
, {"emqx_authn", emqx_authn_schema} , {"authentication", emqx_authn_schema}
, {"authorization", emqx_authz_schema} , {"authorization", emqx_authz_schema}
, {"emqx_bridge_mqtt", emqx_bridge_mqtt_schema} , {"emqx_bridge_mqtt", emqx_bridge_mqtt_schema}
, {"emqx_management", emqx_management_schema} , {"emqx_management", emqx_management_schema}