feat(authz): add enable config for connectot in config file
Signed-off-by: zhanghongtong <rory-z@outlook.com>
This commit is contained in:
parent
8ba0890ce5
commit
c1cbd8ece4
|
@ -116,6 +116,7 @@ init_rule(#{topics := Topics,
|
|||
};
|
||||
|
||||
init_rule(#{principal := Principal,
|
||||
enable := true,
|
||||
type := http,
|
||||
config := #{url := Url} = Config
|
||||
} = Rule) ->
|
||||
|
@ -124,6 +125,7 @@ init_rule(#{principal := Principal,
|
|||
NRule#{principal => compile_principal(Principal)};
|
||||
|
||||
init_rule(#{principal := Principal,
|
||||
enable := true,
|
||||
type := DB
|
||||
} = Rule) when DB =:= redis;
|
||||
DB =:= mongo ->
|
||||
|
@ -131,6 +133,7 @@ init_rule(#{principal := Principal,
|
|||
NRule#{principal => compile_principal(Principal)};
|
||||
|
||||
init_rule(#{principal := Principal,
|
||||
enable := true,
|
||||
type := DB,
|
||||
sql := SQL
|
||||
} = Rule) when DB =:= mysql;
|
||||
|
@ -139,7 +142,11 @@ init_rule(#{principal := Principal,
|
|||
NRule = create_resource(Rule),
|
||||
NRule#{principal => compile_principal(Principal),
|
||||
sql => Mod:parse_query(SQL)
|
||||
}.
|
||||
};
|
||||
init_rule(#{enable := false,
|
||||
type := _DB
|
||||
} = Rule) ->
|
||||
Rule.
|
||||
|
||||
compile_principal(all) -> all;
|
||||
compile_principal(#{username := Username}) ->
|
||||
|
|
|
@ -25,6 +25,8 @@ fields("emqx_authz") ->
|
|||
fields(http) ->
|
||||
[ {principal, principal()}
|
||||
, {type, #{type => http}}
|
||||
, {enable, #{type => boolean(),
|
||||
default => true}}
|
||||
, {config, #{type => hoconsc:union([ hoconsc:ref(?MODULE, http_get)
|
||||
, hoconsc:ref(?MODULE, http_post)
|
||||
])}
|
||||
|
@ -188,4 +190,6 @@ connector_fields(DB) ->
|
|||
end,
|
||||
[ {principal, principal()}
|
||||
, {type, #{type => DB}}
|
||||
, {enable, #{type => boolean(),
|
||||
default => true}}
|
||||
] ++ Mod:fields("").
|
||||
|
|
Loading…
Reference in New Issue