Software /
code /
prosody
Changeset
1835:5ae3209fefa2 0.5.2
Merge with waqas
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 27 Sep 2009 12:10:50 +0100 |
parents | 1834:d5a1fd78a06a (current diff) 1833:5408d5100bd0 (diff) |
children | 1836:f4c88dd32724 1838:8abe1d19c878 |
files | |
diffstat | 1 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_legacyauth.lua Sun Sep 27 12:10:36 2009 +0100 +++ b/plugins/mod_legacyauth.lua Sun Sep 27 12:10:50 2009 +0100 @@ -16,6 +16,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) @@ -46,9 +48,11 @@ return true; else username, password, resource = t_concat(username), t_concat(password), t_concat(resource); + username = nodeprep(username); + resource = resourceprep(resource) local reply = st.reply(stanza); require "core.usermanager" - if usermanager.validate_credentials(session.host, username, password) then + if username and resource and usermanager.validate_credentials(session.host, username, password) then -- Authentication successful! local success, err = sessionmanager.make_authenticated(session, username); if success then @@ -56,6 +60,11 @@ 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)); + 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