sasl: Use the nick from the presence if the ad-hoc one is not set

fix #3450
This commit is contained in:
louiz’
2021-01-15 12:33:18 +01:00
parent 1b1b03b21b
commit a4512cd3ae
2 changed files with 31 additions and 3 deletions
+2 -1
View File
@@ -1371,7 +1371,8 @@ void IrcClient::on_authenticate(const IrcMessage &)
auto options = Database::get_irc_server_options(this->bridge.get_bare_jid(), auto options = Database::get_irc_server_options(this->bridge.get_bare_jid(),
this->get_hostname()); this->get_hostname());
const auto auth_string = '\0' + options.col<Database::Nick>() + '\0' + options.col<Database::SaslPassword>(); const auto& nick = !options.col<Database::Nick>().empty() ? options.col<Database::Nick>() : this->get_own_nick();
const auto auth_string = '\0' + nick + '\0' + options.col<Database::SaslPassword>();
const auto base64_auth_string = base64::encode(auth_string); const auto base64_auth_string = base64::encode(auth_string);
this->send_message({"AUTHENTICATE", {base64_auth_string}}); this->send_message({"AUTHENTICATE", {base64_auth_string}});
} }
+29 -2
View File
@@ -40,14 +40,41 @@ scenario = (
send_stanza("<presence from='{jid_one}/{resource_one}' to='#foo%{irc_server_one}/RegisteredUser' type='unavailable' />"), send_stanza("<presence from='{jid_one}/{resource_one}' to='#foo%{irc_server_one}/RegisteredUser' type='unavailable' />"),
expect_stanza("/presence[@type='unavailable']"), expect_stanza("/presence[@type='unavailable']"),
# Configure an INCORRECT password # Leave the same password, but remove the Nick
send_stanza("<iq type='set' id='id3' from='{jid_one}/{resource_one}' to='{irc_server_one}'><command xmlns='http://jabber.org/protocol/commands' node='configure' action='execute' /></iq>"), send_stanza("<iq type='set' id='id3' from='{jid_one}/{resource_one}' to='{irc_server_one}'><command xmlns='http://jabber.org/protocol/commands' node='configure' action='execute' /></iq>"),
expect_stanza("/iq[@type='result']/commands:command[@node='configure'][@sessionid][@status='executing']", expect_stanza("/iq[@type='result']/commands:command[@node='configure'][@sessionid][@status='executing']",
"/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-private'][@var='sasl_password']", "/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-private'][@var='sasl_password']",
after = save_value("sessionid", extract_attribute("/iq[@type='result']/commands:command[@node='configure']", "sessionid"))), after = save_value("sessionid", extract_attribute("/iq[@type='result']/commands:command[@node='configure']", "sessionid"))),
send_stanza("<iq type='set' id='id4' from='{jid_one}/{resource_one}' to='{irc_server_one}'>" send_stanza("<iq type='set' id='id4' from='{jid_one}/{resource_one}' to='{irc_server_one}'>"
"<command xmlns='http://jabber.org/protocol/commands' node='configure' sessionid='{sessionid}' action='complete'>"
"<x xmlns='jabber:x:data' type='submit'>"
"<field var='sasl_password'><value>P4SSW0RD</value></field>"
"<field var='ports'><value>6667</value></field>"
"<field var='nick'><value></value></field>"
"<field var='tls_ports'><value>6697</value><value>6670</value></field>"
"<field var='throttle_limit'><value>9999</value></field>"
"</x></command></iq>"),
expect_stanza("/iq[@type='result']/commands:command[@node='configure'][@status='completed']/commands:note[@type='info'][text()='Configuration successfully applied.']"),
# Joining a channel with the associated nick will work, it will use the one from our <presence/>
send_stanza("<presence from='{jid_one}/{resource_one}' to='#foo%{irc_server_one}/RegisteredUser' ><x xmlns='http://jabber.org/protocol/muc'/></presence>"),
sequences.connection(login="RegisteredUser"),
expect_stanza("/presence"),
expect_stanza("/message/subject"),
# Leave the channel and disconnect from the server to try again differently
send_stanza("<presence from='{jid_one}/{resource_one}' to='#foo%{irc_server_one}/RegisteredUser' type='unavailable' />"),
expect_stanza("/presence[@type='unavailable']"),
# Configure an INCORRECT password
send_stanza("<iq type='set' id='id5' from='{jid_one}/{resource_one}' to='{irc_server_one}'><command xmlns='http://jabber.org/protocol/commands' node='configure' action='execute' /></iq>"),
expect_stanza("/iq[@type='result']/commands:command[@node='configure'][@sessionid][@status='executing']",
"/iq/commands:command/dataform:x[@type='form']/dataform:field[@type='text-private'][@var='sasl_password']",
after = save_value("sessionid", extract_attribute("/iq[@type='result']/commands:command[@node='configure']", "sessionid"))),
send_stanza("<iq type='set' id='id6' from='{jid_one}/{resource_one}' to='{irc_server_one}'>"
"<command xmlns='http://jabber.org/protocol/commands' node='configure' sessionid='{sessionid}' action='complete'>" "<command xmlns='http://jabber.org/protocol/commands' node='configure' sessionid='{sessionid}' action='complete'>"
"<x xmlns='jabber:x:data' type='submit'>" "<x xmlns='jabber:x:data' type='submit'>"
"<field var='sasl_password'><value>wrong wrong wrong</value></field>" "<field var='sasl_password'><value>wrong wrong wrong</value></field>"