From f1362b9856d107ee6fe715b1aa39a711e692eba7 Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Sat, 9 Dec 2006 02:48:52 +0000 Subject: [PATCH] Identifies user authentication ID using SASL PLAIN mechanism Identifies user authentication ID when user authenticates using SASL PLAIN mechanism. It simply base64 decodes the first SASL message sent by client. --- jabber.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/jabber.c b/jabber.c index 1c3f520..81dc849 100644 --- a/jabber.c +++ b/jabber.c @@ -80,9 +80,27 @@ void jabber_connect_server (net_hook_t* hook, char* server, iks* node) g_string_free (buffer, TRUE); } +void +jabber_sasl_plain_filter (iks *node) +{ + if (g_str_equal (iks_name (node), "auth") && + g_str_equal (iks_find_attrib (node, "xmlns"), + "urn:ietf:params:xml:ns:xmpp-sasl")) + { + char *b64; + char *uname; + gsize uname_len; + b64 = iks_cdata (iks_child (node)); + uname = g_base64_decode (b64, &uname_len); + g_message ("User trying authentication as %s", uname); + g_free (uname); + } +} + void jabber_send (net_hook_t* hook, iks* node) { GString* buffer; + jabber_sasl_plain_filter (node); buffer = g_string_new (iks_string (iks_stack (node), node)); gnet_conn_write (hook->peer->conn, buffer->str, buffer->len); g_string_free (buffer, TRUE); -- 2.20.1