Mercurial > prosody-hg
comparison plugins/mod_auth_cyrus.lua @ 3468:d50e2c937717
mod_saslauth, mod_auth_cyrus, util.sasl_cyrus: Moved cyrus account provisioning check out of mod_saslauth.
| author | Waqas Hussain <waqas20@gmail.com> |
|---|---|
| date | Mon, 23 Aug 2010 16:54:56 +0500 |
| parents | 26751c628207 |
| children | 52eaa2590bfb |
comparison
equal
deleted
inserted
replaced
| 3467:c9f4c3aa14a1 | 3468:d50e2c937717 |
|---|---|
| 6 -- COPYING file in the source package for more information. | 6 -- COPYING file in the source package for more information. |
| 7 -- | 7 -- |
| 8 | 8 |
| 9 local log = require "util.logger".init("auth_cyrus"); | 9 local log = require "util.logger".init("auth_cyrus"); |
| 10 | 10 |
| 11 local usermanager_user_exists = require "core.usermanager".user_exists; | |
| 12 | |
| 11 local cyrus_service_realm = module:get_option("cyrus_service_realm"); | 13 local cyrus_service_realm = module:get_option("cyrus_service_realm"); |
| 12 local cyrus_service_name = module:get_option("cyrus_service_name"); | 14 local cyrus_service_name = module:get_option("cyrus_service_name"); |
| 13 local cyrus_application_name = module:get_option("cyrus_application_name"); | 15 local cyrus_application_name = module:get_option("cyrus_application_name"); |
| 16 local require_provisioning = module:get_option("cyrus_require_provisioning") or false; | |
| 14 | 17 |
| 15 prosody.unlock_globals(); --FIXME: Figure out why this is needed and | 18 prosody.unlock_globals(); --FIXME: Figure out why this is needed and |
| 16 -- why cyrussasl isn't caught by the sandbox | 19 -- why cyrussasl isn't caught by the sandbox |
| 17 local cyrus_new = require "util.sasl_cyrus".new; | 20 local cyrus_new = require "util.sasl_cyrus".new; |
| 18 prosody.lock_globals(); | 21 prosody.lock_globals(); |
| 39 function provider.set_password(username, password) | 42 function provider.set_password(username, password) |
| 40 return nil, "Passwords unavailable for Cyrus SASL."; | 43 return nil, "Passwords unavailable for Cyrus SASL."; |
| 41 end | 44 end |
| 42 | 45 |
| 43 function provider.user_exists(username) | 46 function provider.user_exists(username) |
| 47 if require_provisioning then | |
| 48 return usermanager_user_exists(username, module.host); | |
| 49 end | |
| 44 return true; | 50 return true; |
| 45 end | 51 end |
| 46 | 52 |
| 47 function provider.create_user(username, password) | 53 function provider.create_user(username, password) |
| 48 return nil, "Account creation/modification not available with Cyrus SASL."; | 54 return nil, "Account creation/modification not available with Cyrus SASL."; |
| 49 end | 55 end |
| 50 | 56 |
| 51 function provider.get_sasl_handler() | 57 function provider.get_sasl_handler() |
| 52 local realm = module:get_option("sasl_realm") or module.host; | 58 local realm = module:get_option("sasl_realm") or module.host; |
| 53 return new_sasl(realm); | 59 local handler = new_sasl(realm); |
| 60 if require_provisioning then | |
| 61 function handler.require_provisioning(username) | |
| 62 return usermanager_user_exists(username, module.host); | |
| 63 end | |
| 64 end | |
| 65 return handler; | |
| 54 end | 66 end |
| 55 | 67 |
| 56 return provider; | 68 return provider; |
| 57 end | 69 end |
| 58 | 70 |
