Skip to content

Commit

Permalink
According to RFC7617 the password consists of everything following
Browse files Browse the repository at this point in the history
the first colon, including any colons.
  • Loading branch information
gnaeser committed Nov 8, 2023
1 parent fac28a9 commit c3860c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/yaws.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2948,12 +2948,9 @@ parse_auth(Orig = "Basic " ++ Auth64) ->
{error, _Err} ->
{undefined, undefined, Orig};
Auth ->
case string:tokens(Auth, ":") of
[User, Pass ] ->
{User, Pass, Orig};
[User, Pass0 | Extra] ->
%% password can contain :
Pass = join_sep([Pass0 | Extra], ":"),
case string:split(Auth, ":") of
%% Password can contain colons, username cannot (RFC7617).
[User, Pass] when User /= [] ->
{User, Pass, Orig};
_ ->
{undefined, undefined, Orig}
Expand Down
5 changes: 5 additions & 0 deletions testsuite/auth_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ end_per_testcase(_Test, _Config) ->

%%====================================================================
basic_auth(Config) ->
User0 = "foo",
Password0 = "::bar:::frob::::",
{_, Auth0} = auth_header(User0, Password0),
?assertMatch({User0, Password0, Auth0}, yaws:parse_auth(Auth0)),

Port = testsuite:get_yaws_port(1, Config),
Url = testsuite:make_url(http, "127.0.0.1", Port, "/test1/a.txt"),
Auth1 = auth_header("foo", "baz"),
Expand Down

0 comments on commit c3860c1

Please sign in to comment.