rnewson commented on a change in pull request #2661: Enhance alg check
URL: https://github.com/apache/couchdb/pull/2661#discussion_r392388270
##########
File path: src/jwtf/src/jwtf.erl
##########
@@ -139,10 +139,11 @@ validate_alg(Props, Checks) ->
case {Required, Alg} of
{undefined, _} ->
ok;
- {true, undefined} ->
+ {Required, undefined} when Required /= undefined ->
throw({bad_request, <<"Missing alg header parameter">>});
- {true, Alg} ->
- case lists:member(Alg, valid_algorithms()) of
+ {Required, Alg} when Required == true; is_list(Required) ->
+ AllowedAlg = if Required == true -> true; true ->
lists:member(Alg, Required) end,
Review comment:
hm, nope? it's because you can say `[<<"alg">>]` to insist that there _is_
an alg property and `[{<<"alg">>, [<<"FOO">>, <<"BAR">>]}]` to insist that alg
is present and one of the two options. This is the tidiest I could make that
logic.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services