Software /
code /
prosody
Diff
plugins/mod_legacyauth.lua @ 1836:f4c88dd32724
Merge with 0.5
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 27 Sep 2009 12:26:51 +0100 |
parent | 1690:b675ae5b4c91 |
parent | 1833:5408d5100bd0 |
child | 1912:126401a7159f |
line wrap: on
line diff
--- a/plugins/mod_legacyauth.lua Thu Sep 24 23:47:16 2009 +0100 +++ b/plugins/mod_legacyauth.lua Sun Sep 27 12:26:51 2009 +0100 @@ -15,6 +15,8 @@ local sessionmanager = require "core.sessionmanager"; local usermanager = require "core.usermanager"; +local nodeprep = require "util.encodings".stringprep.nodeprep; +local resourceprep = require "util.encodings".stringprep.resourceprep; module:add_feature("jabber:iq:auth"); module:add_event_hook("stream-features", function (session, features) @@ -44,6 +46,8 @@ :tag("resource"):up()); else username, password, resource = t_concat(username), t_concat(password), t_concat(resource); + username = nodeprep(username); + resource = resourceprep(resource) local reply = st.reply(stanza); if usermanager.validate_credentials(session.host, username, password) then -- Authentication successful! @@ -53,7 +57,12 @@ success, err_type, err, err_msg = sessionmanager.bind_resource(session, resource); if not success then session.send(st.error_reply(stanza, err_type, err, err_msg)); - return true; -- FIXME need to unauthenticate here + session.username, session.type = nil, "c2s_unauthed"; -- FIXME should this be placed in sessionmanager? + return true; + elseif resource ~= session.resource then -- server changed resource, not supported by legacy auth + session.send(st.error_reply(stanza, "cancel", "conflict", "The requested resource could not be assigned to this session.")); + session:close(); -- FIXME undo resource bind and auth instead of closing the session? + return true; end end session.send(st.reply(stanza));