Software /
code /
prosody
Comparison
plugins/mod_legacyauth.lua @ 1831:ced7a6b8bcd0
mod_legacyauth: Added node and resource prepping.
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Sun, 27 Sep 2009 15:21:08 +0500 |
parent | 1523:841d61be198f |
child | 1832:a805e4fe104a |
comparison
equal
deleted
inserted
replaced
1827:fc21e8832848 | 1831:ced7a6b8bcd0 |
---|---|
14 local config = require "core.configmanager"; | 14 local config = require "core.configmanager"; |
15 local secure_auth_only = config.get(module:get_host(), "core", "require_encryption"); | 15 local secure_auth_only = config.get(module:get_host(), "core", "require_encryption"); |
16 | 16 |
17 local sessionmanager = require "core.sessionmanager"; | 17 local sessionmanager = require "core.sessionmanager"; |
18 local usermanager = require "core.usermanager"; | 18 local usermanager = require "core.usermanager"; |
19 local nodeprep = require "util.encodings".stringprep.nodeprep; | |
20 local resourceprep = require "util.encodings".stringprep.resourceprep; | |
19 | 21 |
20 module:add_feature("jabber:iq:auth"); | 22 module:add_feature("jabber:iq:auth"); |
21 module:add_event_hook("stream-features", function (session, features) | 23 module:add_event_hook("stream-features", function (session, features) |
22 if secure_auth_only and not session.secure then | 24 if secure_auth_only and not session.secure then |
23 -- Sorry, not offering to insecure streams! | 25 -- Sorry, not offering to insecure streams! |
44 :tag("password"):up() | 46 :tag("password"):up() |
45 :tag("resource"):up()); | 47 :tag("resource"):up()); |
46 return true; | 48 return true; |
47 else | 49 else |
48 username, password, resource = t_concat(username), t_concat(password), t_concat(resource); | 50 username, password, resource = t_concat(username), t_concat(password), t_concat(resource); |
51 username = nodeprep(username); | |
52 resource = resourceprep(resource) | |
49 local reply = st.reply(stanza); | 53 local reply = st.reply(stanza); |
50 require "core.usermanager" | 54 require "core.usermanager" |
51 if usermanager.validate_credentials(session.host, username, password) then | 55 if username and usermanager.validate_credentials(session.host, username, password) then |
52 -- Authentication successful! | 56 -- Authentication successful! |
53 local success, err = sessionmanager.make_authenticated(session, username); | 57 local success, err = sessionmanager.make_authenticated(session, username); |
54 if success then | 58 if success then |
55 local err_type, err_msg; | 59 local err_type, err_msg; |
56 success, err_type, err, err_msg = sessionmanager.bind_resource(session, resource); | 60 success, err_type, err, err_msg = sessionmanager.bind_resource(session, resource); |