Make shim for mod_http_api admin_ip_access more robust

This commit is contained in:
Paweł Chmielowski 2017-01-20 10:19:09 +01:00
parent 4f5d54f062
commit 1f02567507
1 changed files with 22 additions and 20 deletions

View File

@ -539,26 +539,28 @@ permission_addon() ->
fun(V) -> V end, fun(V) -> V end,
none), none),
Rules = acl:resolve_access(Access, global), Rules = acl:resolve_access(Access, global),
R = lists:filtermap( R = case Rules of
fun({V, AclRules}) when V == all; V == [all]; V == [allow]; V == allow -> all ->
{true, {[{allow, AclRules}], {[<<"*">>], []}}}; [{[{allow, all}], {all, []}}];
({List, AclRules}) when is_list(List) -> none ->
{true, {[{allow, AclRules}], {List, []}}}; [];
(_) -> _ ->
false lists:filtermap(
end, Rules), fun({V, AclRules}) when V == all; V == [all]; V == [allow]; V == allow ->
case R of {true, {[{allow, AclRules}], {all, []}}};
[] -> ({List, AclRules}) when is_list(List) ->
none; {true, {[{allow, AclRules}], {List, []}}};
_ -> (_) ->
{_, Res} = lists:foldl( false
fun({R2, L2}, {Idx, Acc}) -> end, Rules)
{Idx+1, [{<<"'mod_http_api admin_ip_access' option compatibility shim ", end,
(integer_to_binary(Idx))/binary>>, {_, Res} = lists:foldl(
{[?MODULE], [{access, R2}], L2}} | Acc]} fun({R2, L2}, {Idx, Acc}) ->
end, {1, []}, R), {Idx+1, [{<<"'mod_http_api admin_ip_access' option compatibility shim ",
Res (integer_to_binary(Idx))/binary>>,
end. {[?MODULE], [{access, R2}], L2}} | Acc]}
end, {1, []}, R),
Res.
mod_opt_type(admin_ip_access) -> fun acl:access_rules_validator/1; mod_opt_type(admin_ip_access) -> fun acl:access_rules_validator/1;
mod_opt_type(_) -> [admin_ip_access]. mod_opt_type(_) -> [admin_ip_access].