Mercurial > prosody-hg
comparison plugins/mod_saslauth.lua @ 2450:03bb0e6d87d5
mod_saslauth: Made some variables local to avoid unnecessary global access.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Mon, 11 Jan 2010 19:05:08 +0500 |
| parents | c35deaea53b9 |
| children | d2f747920eaf |
comparison
equal
deleted
inserted
replaced
| 2449:678ca4e9a479 | 2450:03bb0e6d87d5 |
|---|---|
| 34 local xmlns_bind ='urn:ietf:params:xml:ns:xmpp-bind'; | 34 local xmlns_bind ='urn:ietf:params:xml:ns:xmpp-bind'; |
| 35 local xmlns_stanzas ='urn:ietf:params:xml:ns:xmpp-stanzas'; | 35 local xmlns_stanzas ='urn:ietf:params:xml:ns:xmpp-stanzas'; |
| 36 | 36 |
| 37 local new_sasl | 37 local new_sasl |
| 38 if sasl_backend == "cyrus" then | 38 if sasl_backend == "cyrus" then |
| 39 cyrus_new = require "util.sasl_cyrus".new; | 39 local cyrus_new = require "util.sasl_cyrus".new; |
| 40 new_sasl = function(realm) | 40 new_sasl = function(realm) |
| 41 return cyrus_new(realm, module:get_option("cyrus_service_name") or "xmpp") | 41 return cyrus_new(realm, module:get_option("cyrus_service_name") or "xmpp") |
| 42 end | 42 end |
| 43 else | 43 else |
| 44 if sasl_backend ~= "builtin" then module:log("warn", "Unknown SASL backend %s", sasl_backend) end; | 44 if sasl_backend ~= "builtin" then module:log("warn", "Unknown SASL backend %s", sasl_backend) end; |
| 45 new_sasl = require "util.sasl".new; | 45 new_sasl = require "util.sasl".new; |
| 46 end | 46 end |
| 47 | 47 |
| 48 default_authentication_profile = { | 48 local default_authentication_profile = { |
| 49 plain = function(username, realm) | 49 plain = function(username, realm) |
| 50 local prepped_username = nodeprep(username); | 50 local prepped_username = nodeprep(username); |
| 51 if not prepped_username then | 51 if not prepped_username then |
| 52 log("debug", "NODEprep failed on username: %s", username); | 52 log("debug", "NODEprep failed on username: %s", username); |
| 53 return "", nil; | 53 return "", nil; |
| 54 end | |
| 55 local password = usermanager_get_password(prepped_username, realm); | |
| 56 if not password then | |
| 57 return "", nil; | |
| 58 end | |
| 59 return password, true; | |
| 60 end | 54 end |
| 55 local password = usermanager_get_password(prepped_username, realm); | |
| 56 if not password then | |
| 57 return "", nil; | |
| 58 end | |
| 59 return password, true; | |
| 60 end | |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 anonymous_authentication_profile = { | 63 local anonymous_authentication_profile = { |
| 64 anonymous = function(username, realm) | 64 anonymous = function(username, realm) |
| 65 return true; -- for normal usage you should always return true here | 65 return true; -- for normal usage you should always return true here |
| 66 end | 66 end |
| 67 } | 67 }; |
| 68 | 68 |
| 69 local function build_reply(status, ret, err_msg) | 69 local function build_reply(status, ret, err_msg) |
| 70 local reply = st.stanza(status, {xmlns = xmlns_sasl}); | 70 local reply = st.stanza(status, {xmlns = xmlns_sasl}); |
| 71 if status == "challenge" then | 71 if status == "challenge" then |
| 72 log("debug", "%s", ret or ""); | 72 log("debug", "%s", ret or ""); |
