Software /
code /
verse
Diff
plugins/sasl.lua @ 315:3742107e2505
plugins/sasl: Use ANONYMOUS authentication when no username provided
author | James Callahan <james@chatid.com> |
---|---|
date | Mon, 10 Sep 2012 23:37:04 +1000 |
parent | 302:0c83cb476246 |
child | 354:58cd27b74ba5 |
line wrap: on
line diff
--- a/plugins/sasl.lua Fri Aug 31 19:40:14 2012 +0200 +++ b/plugins/sasl.lua Mon Sep 10 23:37:04 2012 +1000 @@ -5,12 +5,16 @@ local function handle_features(features_stanza) if stream.authenticated then return; end stream:debug("Authenticating with SASL..."); - local initial_data = base64("\0"..stream.username.."\0"..stream.password); - --stream.sasl_state, initial_data = sasl_new({"PLAIN"}, stream.username, stream.password, stream.jid); - - stream:debug("Selecting PLAIN mechanism..."); - local auth_stanza = verse.stanza("auth", { xmlns = xmlns_sasl, mechanism = "PLAIN" }); + local mechanism , initial_data + if stream.username then + mechanism = "PLAIN" + initial_data = base64("\0"..stream.username.."\0"..stream.password); + else + mechanism = "ANONYMOUS" + end + stream:debug("Selecting %s mechanism...",mechanism); + local auth_stanza = verse.stanza("auth", { xmlns = xmlns_sasl, mechanism = mechanism }); if initial_data then auth_stanza:text(initial_data); end