fix(authz): ensure acl.conf path template rendered
This commit is contained in:
parent
a3b1664c06
commit
c825102bed
|
@ -205,7 +205,7 @@ sources(get, _) ->
|
|||
},
|
||||
AccIn
|
||||
) ->
|
||||
case file:read_file(Path) of
|
||||
case emqx_authz_file:read_file(Path) of
|
||||
{ok, Rules} ->
|
||||
lists:append(AccIn, [
|
||||
#{
|
||||
|
@ -242,7 +242,7 @@ source(get, #{bindings := #{type := Type}}) ->
|
|||
Type,
|
||||
fun
|
||||
(#{<<"type">> := <<"file">>, <<"enable">> := Enable, <<"path">> := Path}) ->
|
||||
case file:read_file(Path) of
|
||||
case emqx_authz_file:read_file(Path) of
|
||||
{ok, Rules} ->
|
||||
{200, #{
|
||||
type => file,
|
||||
|
|
|
@ -32,14 +32,15 @@
|
|||
create/1,
|
||||
update/1,
|
||||
destroy/1,
|
||||
authorize/4
|
||||
authorize/4,
|
||||
read_file/1
|
||||
]).
|
||||
|
||||
description() ->
|
||||
"AuthZ with static rules".
|
||||
|
||||
create(#{path := Path0} = Source) ->
|
||||
Path = emqx_schema:naive_env_interpolation(Path0),
|
||||
Path = filename(Path0),
|
||||
Rules =
|
||||
case file:consult(Path) of
|
||||
{ok, Terms} ->
|
||||
|
@ -64,3 +65,9 @@ destroy(_Source) -> ok.
|
|||
|
||||
authorize(Client, PubSub, Topic, #{annotations := #{rules := Rules}}) ->
|
||||
emqx_authz_rule:matches(Client, PubSub, Topic, Rules).
|
||||
|
||||
read_file(Path) ->
|
||||
file:read_file(filename(Path)).
|
||||
|
||||
filename(PathMaybeTemplate) ->
|
||||
emqx_schema:naive_env_interpolation(PathMaybeTemplate).
|
||||
|
|
Loading…
Reference in New Issue