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,
|
init_rule(#{principal := Principal,
|
||||||
|
enable := true,
|
||||||
type := http,
|
type := http,
|
||||||
config := #{url := Url} = Config
|
config := #{url := Url} = Config
|
||||||
} = Rule) ->
|
} = Rule) ->
|
||||||
|
@ -124,6 +125,7 @@ init_rule(#{principal := Principal,
|
||||||
NRule#{principal => compile_principal(Principal)};
|
NRule#{principal => compile_principal(Principal)};
|
||||||
|
|
||||||
init_rule(#{principal := Principal,
|
init_rule(#{principal := Principal,
|
||||||
|
enable := true,
|
||||||
type := DB
|
type := DB
|
||||||
} = Rule) when DB =:= redis;
|
} = Rule) when DB =:= redis;
|
||||||
DB =:= mongo ->
|
DB =:= mongo ->
|
||||||
|
@ -131,6 +133,7 @@ init_rule(#{principal := Principal,
|
||||||
NRule#{principal => compile_principal(Principal)};
|
NRule#{principal => compile_principal(Principal)};
|
||||||
|
|
||||||
init_rule(#{principal := Principal,
|
init_rule(#{principal := Principal,
|
||||||
|
enable := true,
|
||||||
type := DB,
|
type := DB,
|
||||||
sql := SQL
|
sql := SQL
|
||||||
} = Rule) when DB =:= mysql;
|
} = Rule) when DB =:= mysql;
|
||||||
|
@ -139,7 +142,11 @@ init_rule(#{principal := Principal,
|
||||||
NRule = create_resource(Rule),
|
NRule = create_resource(Rule),
|
||||||
NRule#{principal => compile_principal(Principal),
|
NRule#{principal => compile_principal(Principal),
|
||||||
sql => Mod:parse_query(SQL)
|
sql => Mod:parse_query(SQL)
|
||||||
}.
|
};
|
||||||
|
init_rule(#{enable := false,
|
||||||
|
type := _DB
|
||||||
|
} = Rule) ->
|
||||||
|
Rule.
|
||||||
|
|
||||||
compile_principal(all) -> all;
|
compile_principal(all) -> all;
|
||||||
compile_principal(#{username := Username}) ->
|
compile_principal(#{username := Username}) ->
|
||||||
|
|
|
@ -25,6 +25,8 @@ fields("emqx_authz") ->
|
||||||
fields(http) ->
|
fields(http) ->
|
||||||
[ {principal, principal()}
|
[ {principal, principal()}
|
||||||
, {type, #{type => http}}
|
, {type, #{type => http}}
|
||||||
|
, {enable, #{type => boolean(),
|
||||||
|
default => true}}
|
||||||
, {config, #{type => hoconsc:union([ hoconsc:ref(?MODULE, http_get)
|
, {config, #{type => hoconsc:union([ hoconsc:ref(?MODULE, http_get)
|
||||||
, hoconsc:ref(?MODULE, http_post)
|
, hoconsc:ref(?MODULE, http_post)
|
||||||
])}
|
])}
|
||||||
|
@ -188,4 +190,6 @@ connector_fields(DB) ->
|
||||||
end,
|
end,
|
||||||
[ {principal, principal()}
|
[ {principal, principal()}
|
||||||
, {type, #{type => DB}}
|
, {type, #{type => DB}}
|
||||||
|
, {enable, #{type => boolean(),
|
||||||
|
default => true}}
|
||||||
] ++ Mod:fields("").
|
] ++ Mod:fields("").
|
||||||
|
|
Loading…
Reference in New Issue