You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2020/03/13 10:35:21 UTC

[GitHub] [couchdb] rnewson opened a new pull request #2661: Enhance alg check

rnewson opened a new pull request #2661: Enhance alg check
URL: https://github.com/apache/couchdb/pull/2661
 
 
   ## Overview
   
   The "alg" check can now take list of algorithms that are supported,
   which must be from the valid list of algorithms.
   
   ## Testing recommendations
   
   The new functionality is covered by eunit tests.
   
   ## Related Issues or Pull Requests
   
   https://github.com/apache/couchdb/pull/2648/
   
   ## Checklist
   
   - [x] Code is written and works correctly
   - [x] Changes are covered by tests
   - [ ] Any new configurable parameters are documented in `rel/overlay/etc/default.ini`
   - [ ] A PR for documentation changes has been made in https://github.com/apache/couchdb-documentation
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [couchdb] rnewson merged pull request #2661: Enhance alg check

Posted by GitBox <gi...@apache.org>.
rnewson merged pull request #2661: Enhance alg check
URL: https://github.com/apache/couchdb/pull/2661
 
 
   

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [couchdb] rnewson commented on a change in pull request #2661: Enhance alg check

Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [couchdb] jaydoane commented on a change in pull request #2661: Enhance alg check

Posted by GitBox <gi...@apache.org>.
jaydoane commented on a change in pull request #2661: Enhance alg check
URL: https://github.com/apache/couchdb/pull/2661#discussion_r392382793
 
 

 ##########
 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:
   This logic is a bit awkward, but I assume it's being done for backward compatibility.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services