]> granicus.if.org Git - ejabberd/commitdiff
Fix parsing of acl/access rules inside oauth sections of api_permissions
authorPaweł Chmielowski <pchmielowski@process-one.net>
Mon, 27 Feb 2017 19:23:24 +0000 (20:23 +0100)
committerPaweł Chmielowski <pchmielowski@process-one.net>
Mon, 27 Feb 2017 19:23:37 +0000 (20:23 +0100)
This should fix problem reported in #1568

src/ejabberd_access_permissions.erl

index 3c4322582d251f0de2a7e2c5042df786529d63f5..fbbc29a8f5e9f335a2fce3243f586b26e4522063 100644 (file)
@@ -363,7 +363,9 @@ parse_who(Name, Atom, ParseOauth) when is_atom(Atom) ->
     parse_who(Name, [Atom], ParseOauth);
 parse_who(Name, Defs, ParseOauth) when is_list(Defs) ->
     lists:map(
-       fun([{access, Val}]) ->
+      fun([Val]) ->
+             parse_who(Name, [Val], ParseOauth);
+        ({access, Val}) ->
            try acl:access_rules_validator(Val) of
                Rule ->
                    {access, Rule}
@@ -377,7 +379,7 @@ parse_who(Name, Defs, ParseOauth) when is_list(Defs) ->
                    report_error(<<"Invalid access rule '~p' used inside 'who' section for api_permission '~s'">>,
                                 [Val, Name])
            end;
-          ([{oauth, OauthList}]) when is_list(OauthList) ->
+          ({oauth, OauthList}) when is_list(OauthList) ->
               case ParseOauth of
                   oauth ->
                       Nested = parse_who(Name, lists:flatten(OauthList), scope),
@@ -413,7 +415,7 @@ parse_who(Name, Defs, ParseOauth) when is_list(Defs) ->
               end;
           (Atom) when is_atom(Atom) ->
               {acl, {acl, Atom}};
-          ([Other]) ->
+          (Other) ->
               try acl:normalize_spec(Other) of
                   Rule2 ->
                       {acl, Rule2}
@@ -421,10 +423,7 @@ parse_who(Name, Defs, ParseOauth) when is_list(Defs) ->
                   _:_ ->
                       report_error(<<"Invalid value '~p' used inside 'who' section for api_permission '~s'">>,
                                    [Other, Name])
-              end;
-          (Invalid) ->
-              report_error(<<"Invalid value '~p' used inside 'who' section for api_permission '~s'">>,
-                           [Invalid, Name])
+              end
        end, Defs);
 parse_who(Name, Val, _ParseOauth) ->
     report_error(<<"Invalid value '~p' used inside 'who' section for api_permission '~s'">>,