iilyak commented on a change in pull request #3637:
URL: https://github.com/apache/couchdb/pull/3637#discussion_r659710282
##########
File path: src/couch/src/couch_httpd_auth.erl
##########
@@ -99,27 +99,32 @@ special_test_authentication_handler(Req) ->
basic_name_pw(Req) ->
AuthorizationHeader = header_value(Req, "Authorization"),
case AuthorizationHeader of
- "Basic " ++ Base64Value ->
- try
- re:split(
- base64:decode(Base64Value),
- ":",
- [{return, list}, {parts, 2}]
- )
- of
- ["_", "_"] ->
- % special name and pass to be logged out
- nil;
- [User, Pass] ->
- {User, Pass};
- _ ->
- nil
- catch
- error:function_clause ->
- throw({bad_request, "Authorization header has invalid
base64 value"})
- end;
+ % undefined is sent during startup process
+ undefined ->
Review comment:
This `undefined` appear to me as a magic value. I think we can flip the
order of clauses to make it more readable and be closer to functionality of
original version (In original version we ignore any unexpected values).
```
basic_name_pw(Req) ->
AuthorizationHeader = header_value(Req, "Authorization"),
case AuthorizationHeader of
Header when is_list(Header) ->
[Basic, Base64Value] = string:split(AuthorizationHeader, " "),
...
_ ->
nil
end.
```
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]