Mercurial > prosody-modules
comparison mod_extauth/mod_extauth.lua @ 166:75a85eac3c27
mod_extauth: Updated to provide a SASL handler.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Thu, 10 Jun 2010 04:35:06 +0500 |
| parents | 1a5d5d4f08fe |
| children |
comparison
equal
deleted
inserted
replaced
| 165:fd8d76daad97 | 166:75a85eac3c27 |
|---|---|
| 22 local command = config.get(host, "core", "extauth_command") or ""; | 22 local command = config.get(host, "core", "extauth_command") or ""; |
| 23 assert(type(command) == "string"); | 23 assert(type(command) == "string"); |
| 24 assert(not host:find(":")); | 24 assert(not host:find(":")); |
| 25 local usermanager = require "core.usermanager"; | 25 local usermanager = require "core.usermanager"; |
| 26 local jid_bare = require "util.jid".bare; | 26 local jid_bare = require "util.jid".bare; |
| 27 local new_sasl = require "util.sasl".new; | |
| 27 | 28 |
| 28 --local proc; | 29 --local proc; |
| 29 local pid; | 30 local pid; |
| 30 local readfile; | 31 local readfile; |
| 31 local writefile; | 32 local writefile; |
| 102 return do_query("isuser", username); | 103 return do_query("isuser", username); |
| 103 end | 104 end |
| 104 | 105 |
| 105 function provider.create_user(username, password) return nil, "Account creation/modification not available."; end | 106 function provider.create_user(username, password) return nil, "Account creation/modification not available."; end |
| 106 | 107 |
| 107 function provider.get_supported_methods() return {["PLAIN"] = true}; end | 108 function provider.get_sasl_handler() |
| 109 local realm = module:get_option("sasl_realm") or module.host; | |
| 110 local testpass_authentication_profile = { | |
| 111 plain_test = function(username, password, realm) | |
| 112 local prepped_username = nodeprep(username); | |
| 113 if not prepped_username then | |
| 114 log("debug", "NODEprep failed on username: %s", username); | |
| 115 return "", nil; | |
| 116 end | |
| 117 return usermanager.test_password(prepped_username, password, realm), true; | |
| 118 end, | |
| 119 }; | |
| 120 return new_sasl(realm, testpass_authentication_profile); | |
| 121 end | |
| 108 | 122 |
| 109 function provider.is_admin(jid) | 123 function provider.is_admin(jid) |
| 110 local admins = config.get(host, "core", "admins"); | 124 local admins = config.get(host, "core", "admins"); |
| 111 if admins ~= config.get("*", "core", "admins") then | 125 if admins ~= config.get("*", "core", "admins") then |
| 112 if type(admins) == "table" then | 126 if type(admins) == "table" then |
