-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C2S/SASL #4101
C2S/SASL #4101
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## feature/sasl2 #4101 +/- ##
=================================================
- Coverage 83.92% 83.91% -0.01%
=================================================
Files 551 552 +1
Lines 33596 33642 +46
=================================================
+ Hits 28195 28232 +37
- Misses 5401 5410 +9
☔ View full report in Codecov by Sentry. |
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's nice to see how the SASL parts are being extracted. I added some comments.
src/c2s/mongoose_c2s.erl
Outdated
|
||
-spec handle_sasl_abort(data(), mongoose_acc:t(), retries()) -> fsm_res(). | ||
handle_sasl_abort(StateData, SaslAcc, Retries) -> | ||
Error = #{server_out => <<"aborted">>, maybe_username => StateData#c2s_data.jid}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we call JID "username"?
src/c2s/mongoose_c2s.erl
Outdated
handle_sasl_failure(#c2s_data{host_type = HostType, lserver = LServer} = StateData, SaslAcc, | ||
#{server_out := ServerOut, maybe_username := Username}, Retries) -> | ||
?LOG_INFO(#{what => auth_failed, text => <<"Failed SASL authentication">>, | ||
jid => Username, c2s_state => StateData}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So is it a JID or user name? I am confused.
src/c2s/mongoose_c2s_sasl.erl
Outdated
handle_sasl_failure(C2SData, Error, Username, _, SaslAcc) -> | ||
LServer = mongoose_c2s:get_lserver(C2SData), | ||
NewJid = jid:make_bare(Username, LServer), | ||
{failure, SaslAcc, #{server_out => Error, maybe_username => NewJid}}. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really strange - the code keeps jumping between JID
and username
- like here between lines 96 and 100.
src/c2s/mongoose_c2s_sasl.erl
Outdated
mongoose_c2s:data(), term(), maybe_username(), maybe_username(), mongoose_acc:t()) -> result(). | ||
handle_sasl_failure(_C2SData, Error, undefined, undefined, SaslAcc) -> | ||
{failure, SaslAcc, #{server_out => Error, maybe_username => undefined}}; | ||
handle_sasl_failure(_C2SData, Error, undefined, #jid{luser = Username}, SaslAcc) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for sure against the spec (double username). Is it reachable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed it is the only line of code not covered by tests in this module, now it will have 100% coverage, good catch! 😛
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added minor comments.
src/c2s/mongoose_c2s_sasl.erl
Outdated
handle_sasl_failure(C2SData, Error, Username, undefined, SaslAcc); | ||
handle_sasl_step(C2SData, {error, Error}, SaslAcc) -> | ||
Jid = mongoose_c2s:get_jid(C2SData), | ||
handle_sasl_failure(C2SData, Error, undefined, Jid, SaslAcc). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as before, passing Jid while the type is maybe_username()
.
big_tests/tests/mim_c2s_SUITE.erl
Outdated
@@ -119,6 +121,16 @@ message_sent_to_malformed_jid_results_in_error(Config) -> | |||
escalus_assert:is_chat_message(<<"Hi!">>, escalus_client:wait_for_stanza(Bob)) | |||
end). | |||
|
|||
invalid_resource_fails_to_log(Config) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't this already done in a merged PR? Maybe rebase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I did and yet dunno why this shows up here, just rebased again.
elasticsearch_and_cassandra_25 / elasticsearch_and_cassandra_mnesia / abb89da small_tests_24 / small_tests / abb89da small_tests_25 / small_tests / abb89da small_tests_25_arm64 / small_tests / abb89da ldap_mnesia_24 / ldap_mnesia / abb89da dynamic_domains_mysql_redis_25 / mysql_redis / abb89da dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / abb89da ldap_mnesia_25 / ldap_mnesia / abb89da dynamic_domains_pgsql_mnesia_25 / pgsql_mnesia / abb89da internal_mnesia_25 / internal_mnesia / abb89da dynamic_domains_mssql_mnesia_25 / odbc_mssql_mnesia / abb89da mysql_redis_25 / mysql_redis / abb89da pgsql_mnesia_24 / pgsql_mnesia / abb89da bosh_SUITE:essential_https:accept_higher_hold_value{error,
{{assertEqual,
[{module,bosh_SUITE},
{line,260},
{expression,"get_bosh_sessions ( )"},
{expected,[]},
{value,
[{bosh_session,<<"5609d62ed9b946b9d86c3c2d98b7bc0a87484cbc">>,
<8854.10235.0>}]}]},
[{bosh_SUITE,accept_higher_hold_value,1,
[{file,"/home/circleci/project/big_tests/tests/bosh_SUITE.erl"},
{line,260}]},
{test_server,ts_tc,3,[{file,"test_server.erl"},{line,1783}]},
{test_server,run_test_case_eval1,6,
[{file,"test_server.erl"},{line,1292}]},
{test_server,run_test_case_eval,9,
[{file,"test_server.erl"},{line,1224}]}]}} pgsql_cets_25 / pgsql_cets / abb89da pgsql_mnesia_25 / pgsql_mnesia / abb89da mssql_mnesia_25 / odbc_mssql_mnesia / abb89da pgsql_mnesia_24 / pgsql_mnesia / abb89da |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👌
An initial refactoring of SASL out of C2S.
I chose accumulators as the SASL state because they also enable tracing trough refs and timing through their timestamps.