Procházet zdrojové kódy

refactor: delete default authz config from emqx.conf

Zaiming (Stone) Shi před 2 roky
rodič
revize
5acf0e281e

+ 0 - 10
apps/emqx_authz/etc/emqx_authz.conf

@@ -2,14 +2,4 @@ authorization {
   deny_action = ignore
   no_match = allow
   cache = { enable = true }
-  sources =  [
-    {
-      type = file
-      enable = true
-      # This file is immutable to EMQX.
-      # Once new rules are created from dashboard UI or HTTP API,
-      # the file 'data/authz/acl.conf' is used instead of this one
-      path = "{{ platform_etc_dir }}/acl.conf"
-    }
-  ]
 }

+ 2 - 1
apps/emqx_authz/src/emqx_authz_file.erl

@@ -38,7 +38,8 @@
 description() ->
     "AuthZ with static rules".
 
-create(#{path := Path} = Source) ->
+create(#{path := Path0} = Source) ->
+    Path = emqx_schema:naive_env_interpolation(Path0),
     Rules =
         case file:consult(Path) of
             {ok, Terms} ->

+ 8 - 1
apps/emqx_authz/src/emqx_authz_schema.erl

@@ -491,7 +491,7 @@ authz_fields() ->
             ?HOCON(
                 ?ARRAY(?UNION(UnionMemberSelector)),
                 #{
-                    default => [],
+                    default => [default_authz()],
                     desc => ?DESC(sources),
                     %% doc_lift is force a root level reference instead of nesting sub-structs
                     extra => #{doc_lift => true},
@@ -501,3 +501,10 @@ authz_fields() ->
                 }
             )}
     ].
+
+default_authz() ->
+    #{
+        <<"type">> => <<"file">>,
+        <<"enable">> => true,
+        <<"path">> => <<"${EMQX_ETC_DIR}/acl.conf">>
+    }.