summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/JabberG/src/jabber_caps.h1
-rw-r--r--protocols/JabberG/src/jabber_strm_mgmt.cpp1
-rw-r--r--protocols/JabberG/src/jabber_thread.cpp46
3 files changed, 32 insertions, 16 deletions
diff --git a/protocols/JabberG/src/jabber_caps.h b/protocols/JabberG/src/jabber_caps.h
index c6981be3a7..50da211ac5 100644
--- a/protocols/JabberG/src/jabber_caps.h
+++ b/protocols/JabberG/src/jabber_caps.h
@@ -202,6 +202,7 @@ typedef unsigned __int64 JabberCapsBits;
#define JABBER_FEAT_CSI "urn:xmpp:csi:0"
#define JABBER_FEAT_JUD "jabber:iq:search"
#define JABBER_FEAT_IDLE "urn:xmpp:idle:1"
+#define JABBER_FEAT_SASL "urn:ietf:params:xml:ns:xmpp-sasl"
#define JABBER_FEAT_SASL2 "urn:xmpp:sasl:2"
#define JABBER_FEAT_SERVER_AVATAR "storage:client:avatar"
#define JABBER_FEAT_SID "urn:xmpp:sid:0"
diff --git a/protocols/JabberG/src/jabber_strm_mgmt.cpp b/protocols/JabberG/src/jabber_strm_mgmt.cpp
index c92ba4ea98..9e8a238c2d 100644
--- a/protocols/JabberG/src/jabber_strm_mgmt.cpp
+++ b/protocols/JabberG/src/jabber_strm_mgmt.cpp
@@ -66,7 +66,6 @@ void strm_mgmt::OnProcessResumed(const TiXmlElement *node, ThreadData * /*info*/
m_bPendingEnable = false;
m_tConnLostTime = 0;
- //FinishLoginProcess(info);
proto->OnLoggedIn();
proto->ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)proto->m_iStatus, proto->m_iDesiredStatus);
ProcessCache(node->IntAttribute("h", -1), true);
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp
index b5b13ce4ec..77bad05c20 100644
--- a/protocols/JabberG/src/jabber_thread.cpp
+++ b/protocols/JabberG/src/jabber_thread.cpp
@@ -634,8 +634,15 @@ void CJabberProto::PerformAuthentication(ThreadData *info)
return;
}
+ // grab the safest mechanism and proceed
auto &auth = m_arAuthMechs[0];
- info->send(XmlNode("auth", ptrA(auth.getInitialRequest())) << XATTR("xmlns", "urn:ietf:params:xml:ns:xmpp-sasl") << XATTR("mechanism", auth.getName()));
+
+ if (m_hasSasl2) {
+ XmlNode node("authenticate");
+ node << XATTR("xmlns", JABBER_FEAT_SASL2) << XATTR("mechanism", auth.getName()) << XCHILD("initial-response", auth.getInitialRequest());
+ info->send(node);
+ }
+ else info->send(XmlNode("auth", ptrA(auth.getInitialRequest())) << XATTR("xmlns", JABBER_FEAT_SASL) << XATTR("mechanism", auth.getName()));
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -756,7 +763,7 @@ void CJabberProto::OnProcessFailure(const TiXmlElement *node, ThreadData *info)
{
// failure xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\"
const char *type = XmlGetAttr(node, "xmlns");
- if (!mir_strcmp(type, "urn:ietf:params:xml:ns:xmpp-sasl")) {
+ if (!mir_strcmp(type, JABBER_FEAT_SASL) || !mir_strcmp(type, JABBER_FEAT_SASL2)) {
m_arAuthMechs.remove(0L);
PerformAuthentication(info);
}
@@ -812,20 +819,28 @@ void CJabberProto::OnProcessSuccess(const TiXmlElement *node, ThreadData *info)
if ((type = XmlGetAttr(node, "xmlns")) == nullptr)
return;
- if (!mir_strcmp(type, "urn:ietf:params:xml:ns:xmpp-sasl")) {
- if (!m_arAuthMechs[0].validateLogin(node->GetText())) {
- info->send("</stream:stream>");
- return;
- }
+ const char *pszFinal;
+ if (!mir_strcmp(type, JABBER_FEAT_SASL))
+ pszFinal = node->GetText();
+ else if (!mir_strcmp(type, JABBER_FEAT_SASL2))
+ pszFinal = XmlGetChildText(node, "additional-data");
+ else {
+ debugLogA("Success: unknown action %s.", type);
+ return;
+ }
+
+ if (!pszFinal || !m_arAuthMechs[0].validateLogin(pszFinal)) {
+ info->send("</stream:stream>");
+ return;
+ }
- debugLogA("Success: Logged-in.");
- ptrA szNick(getUStringA("Nick"));
- if (!mir_strlen(szNick))
- setUString("Nick", info->conn.username);
+ debugLogA("Success: Logged-in.");
+ ptrA szNick(getUStringA("Nick"));
+ if (!mir_strlen(szNick))
+ setUString("Nick", info->conn.username);
+ if (!m_hasSasl2)
xmlStreamInitialize("after successful sasl");
- }
- else debugLogA("Success: unknown action %s.", type);
}
void CJabberProto::OnProcessChallenge(const TiXmlElement *node, ThreadData *info)
@@ -835,11 +850,12 @@ void CJabberProto::OnProcessChallenge(const TiXmlElement *node, ThreadData *info
return;
}
- if (mir_strcmp(XmlGetAttr(node, "xmlns"), "urn:ietf:params:xml:ns:xmpp-sasl"))
+ auto *xmlns = XmlGetAttr(node, "xmlns");
+ if (mir_strcmp(xmlns, JABBER_FEAT_SASL) && mir_strcmp(xmlns, JABBER_FEAT_SASL2))
return;
char *challenge = m_arAuthMechs[0].getChallenge(node->GetText());
- info->send(XmlNode("response", challenge) << XATTR("xmlns", "urn:ietf:params:xml:ns:xmpp-sasl"));
+ info->send(XmlNode("response", challenge) << XATTR("xmlns", xmlns));
mir_free(challenge);
}