Skip to content

Commit f00cb69

Browse files
authored
Merge pull request #18 from niecore/fix-channel-binding-GS2-y
Fix server-side channel binding verification for y GS2 flag
2 parents 077a0b1 + 96b9a91 commit f00cb69

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/fast_scram_parse_rules.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ supported_channel_binding_flag(
245245
<<"y">>,
246246
#channel_binding{variant = undefined} = CbConfig
247247
) ->
248-
CbConfig;
248+
CbConfig#channel_binding{variant = none};
249249
supported_channel_binding_flag(
250250
<<"y">>,
251251
#channel_binding{variant = Type}

test/scram_SUITE.erl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,15 @@ channel_server_offers_but_client_does_not_take_is_ok(_Config) ->
504504
{continue, _, _} = fast_scram:mech_step(ServerState2, YesGS2Flag).
505505

506506
channel_not_advertise_but_client_could_is_ok(_Config) ->
507+
{ok, ClientState1} = fast_scram:mech_new(
508+
#{
509+
entity => client,
510+
hash_method => sha,
511+
username => <<"user">>,
512+
channel_binding => {none, <<>>},
513+
auth_data => #{password => <<"pencil">>}
514+
}
515+
),
507516
{ok, ServerState2} = fast_scram:mech_new(
508517
#{
509518
entity => server,
@@ -518,8 +527,11 @@ channel_not_advertise_but_client_could_is_ok(_Config) ->
518527
end
519528
}
520529
),
521-
YesGS2Flag = <<"y,,n=user,r=fyko+d2lbbFgONRv9qkxdawL">>,
522-
{continue, _, _} = fast_scram:mech_step(ServerState2, YesGS2Flag).
530+
{continue, ClientFirst, ClientState3} = fast_scram:mech_step(ClientState1, <<>>),
531+
{continue, ServerFirst, ServerState4} = fast_scram:mech_step(ServerState2, ClientFirst),
532+
{continue, ClientFinal, ClientState5} = fast_scram:mech_step(ClientState3, ServerFirst),
533+
{ok, ServerFinal, _} = fast_scram:mech_step(ServerState4, ClientFinal),
534+
{ok, _, _} = fast_scram:mech_step(ClientState5, ServerFinal).
523535

524536
%% If the channel binding flag was "p" and the server does not support
525537
%% the indicated channel binding type, then the server MUST fail authentication.

0 commit comments

Comments
 (0)