From 5e81a1ae951cfc22d023a7fea84f4809523e2061 Mon Sep 17 00:00:00 2001 From: JimMoen Date: Tue, 8 Mar 2022 16:14:03 +0800 Subject: [PATCH] fix(authz): `POST` method for creating or updating rules for all --- apps/emqx_authz/src/emqx_authz_api_mnesia.erl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/emqx_authz/src/emqx_authz_api_mnesia.erl b/apps/emqx_authz/src/emqx_authz_api_mnesia.erl index 45a813f1d..fd4f5a9e3 100644 --- a/apps/emqx_authz/src/emqx_authz_api_mnesia.erl +++ b/apps/emqx_authz/src/emqx_authz_api_mnesia.erl @@ -222,13 +222,14 @@ schema("/authorization/sources/built-in-database/all") -> , responses => #{200 => swagger_with_example({rules, ?TYPE_REF}, {all, ?PUT_MAP_EXAMPLE})} } - , put => + , post => #{ tags => [<<"authorization">>] - , description => <<"Set the list of rules for all">> + , description => <<"Create/Update the list of rules for all. " + "Set a empty list to clean up rules">> , 'requestBody' => swagger_with_example({rules, ?TYPE_REF}, {all, ?PUT_MAP_EXAMPLE}) , responses => - #{ 204 => <<"Created">> + #{ 204 => <<"Updated">> , 400 => emqx_dashboard_swagger:error_codes( [?BAD_REQUEST], <<"Bad rule schema">>) } @@ -383,7 +384,7 @@ all(get, _) -> } || {Permission, Action, Topic} <- Rules]} } end; -all(put, #{body := #{<<"rules">> := Rules}}) -> +all(post, #{body := #{<<"rules">> := Rules}}) -> emqx_authz_mnesia:store_rules(all, format_rules(Rules)), {204}.