Identifies user authentication ID using SASL PLAIN mechanism
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sat, 9 Dec 2006 02:48:52 +0000 (02:48 +0000)
committerThadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
Sat, 9 Dec 2006 02:48:52 +0000 (02:48 +0000)
Identifies user authentication ID when user authenticates using SASL
PLAIN mechanism. It simply base64 decodes the first SASL message sent
by client.

jabber.c

index 1c3f520..81dc849 100644 (file)
--- 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);