From fb716ae8b2e8f02ffbbb32f6e7b4d623beb28b43 Mon Sep 17 00:00:00 2001 From: zhouzb Date: Tue, 3 Aug 2021 09:21:07 +0800 Subject: [PATCH 1/2] chore(authn rename): rename emqx_authn to authentication --- apps/emqx_authn/etc/emqx_authn.conf | 2 +- apps/emqx_authn/src/emqx_authn_api.erl | 4 ++-- apps/emqx_authn/src/emqx_authn_app.erl | 4 ++-- apps/emqx_authn/src/emqx_authn_schema.erl | 4 ++-- extension_schemas.config | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/emqx_authn/etc/emqx_authn.conf b/apps/emqx_authn/etc/emqx_authn.conf index 8af40fe8f..5ddeb7a32 100644 --- a/apps/emqx_authn/etc/emqx_authn.conf +++ b/apps/emqx_authn/etc/emqx_authn.conf @@ -1,4 +1,4 @@ -emqx_authn: { +authentication: { enable: false authenticators: [ # { diff --git a/apps/emqx_authn/src/emqx_authn_api.erl b/apps/emqx_authn/src/emqx_authn_api.erl index c0071114a..9477c3e3c 100644 --- a/apps/emqx_authn/src/emqx_authn_api.erl +++ b/apps/emqx_authn/src/emqx_authn_api.erl @@ -1158,12 +1158,12 @@ authentication(post, Request) -> authenticators(post, Request) -> {ok, Body, _} = cowboy_req:read_body(Request), AuthenticatorConfig = emqx_json:decode(Body, [return_maps]), - Config = #{<<"emqx_authn">> => #{ + Config = #{<<"authentication">> => #{ <<"authenticators">> => [AuthenticatorConfig] }}, NConfig = hocon_schema:check_plain(emqx_authn_schema, Config, #{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 {ok, Authenticator2} -> {201, Authenticator2}; diff --git a/apps/emqx_authn/src/emqx_authn_app.erl b/apps/emqx_authn/src/emqx_authn_app.erl index b55727a00..52e59b2a6 100644 --- a/apps/emqx_authn/src/emqx_authn_app.erl +++ b/apps/emqx_authn/src/emqx_authn_app.erl @@ -36,8 +36,8 @@ stop(_State) -> ok. initialize() -> - AuthNConfig = emqx_config:get([emqx_authn], #{enable => false, - authenticators => []}), + AuthNConfig = emqx_config:get([authentication], #{enable => false, + authenticators => []}), initialize(AuthNConfig). initialize(#{enable := Enable, authenticators := AuthenticatorsConfig}) -> diff --git a/apps/emqx_authn/src/emqx_authn_schema.erl b/apps/emqx_authn/src/emqx_authn_schema.erl index 694d5c7ca..6ef742e65 100644 --- a/apps/emqx_authn/src/emqx_authn_schema.erl +++ b/apps/emqx_authn/src/emqx_authn_schema.erl @@ -28,9 +28,9 @@ -export([ authenticator_name/1 ]). -structs() -> [ "emqx_authn" ]. +structs() -> [ "authentication" ]. -fields("emqx_authn") -> +fields("authentication") -> [ {enable, fun enable/1} , {authenticators, fun authenticators/1} ]. diff --git a/extension_schemas.config b/extension_schemas.config index a0a298c1b..1f3b140d8 100644 --- a/extension_schemas.config +++ b/extension_schemas.config @@ -5,7 +5,7 @@ %% [ {"emqx_data_bridge", emqx_data_bridge_schema} , {"emqx_retainer", emqx_retainer_schema} -, {"emqx_authn", emqx_authn_schema} +, {"authentication", emqx_authn_schema} , {"authorization", emqx_authz_schema} , {"emqx_bridge_mqtt", emqx_bridge_mqtt_schema} , {"emqx_management", emqx_management_schema} From 5e9ed72975334b4ebd18777165a14fbd5ccb1c91 Mon Sep 17 00:00:00 2001 From: zhouzb Date: Tue, 3 Aug 2021 09:24:49 +0800 Subject: [PATCH 2/2] chore(authn rename): missing name change --- apps/emqx_authn/src/emqx_authn_api.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/emqx_authn/src/emqx_authn_api.erl b/apps/emqx_authn/src/emqx_authn_api.erl index 9477c3e3c..fe53629de 100644 --- a/apps/emqx_authn/src/emqx_authn_api.erl +++ b/apps/emqx_authn/src/emqx_authn_api.erl @@ -1186,12 +1186,12 @@ authenticators2(put, Request) -> AuthenticatorID = cowboy_req:binding(id, Request), {ok, Body, _} = cowboy_req:read_body(Request), AuthenticatorConfig = emqx_json:decode(Body, [return_maps]), - Config = #{<<"emqx_authn">> => #{ + Config = #{<<"authentication">> => #{ <<"authenticators">> => [AuthenticatorConfig] }}, NConfig = hocon_schema:check_plain(emqx_authn_schema, Config, #{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 {ok, Authenticator} -> {200, Authenticator};