2 -- Copyright (C) 2008-2010 Matthew Wild
3 -- Copyright (C) 2008-2010 Waqas Hussain
4 -- Copyright (C) 2010 Jeff Mitchell
6 -- This project is MIT/X11 licensed. Please see the
7 -- COPYING file in the source package for more information.
10 local log = require "util.logger".init("auth_cyrus");
12 local cyrus_service_realm = module:get_option("cyrus_service_realm");
13 local cyrus_service_name = module:get_option("cyrus_service_name");
14 local cyrus_application_name = module:get_option("cyrus_application_name");
16 prosody.unlock_globals(); --FIXME: Figure out why this is needed and
17 -- why cyrussasl isn't caught by the sandbox
18 local cyrus_new = require "util.sasl_cyrus".new;
19 prosody.lock_globals();
20 local new_sasl = function(realm)
22 cyrus_service_realm or realm,
23 cyrus_service_name or "xmpp",
24 cyrus_application_name or "prosody"
28 function new_default_provider(host)
29 local provider = { name = "cyrus" };
30 log("debug", "initializing default authentication provider for host '%s'", host);
32 function provider.test_password(username, password)
33 return nil, "Legacy auth not supported with Cyrus SASL.";
36 function provider.get_password(username)
37 return nil, "Passwords unavailable for Cyrus SASL.";
40 function provider.set_password(username, password)
41 return nil, "Passwords unavailable for Cyrus SASL.";
44 function provider.user_exists(username)
48 function provider.create_user(username, password)
49 return nil, "Account creation/modification not available with Cyrus SASL.";
52 function provider.get_sasl_handler()
53 local realm = module:get_option("sasl_realm") or module.host;
54 return new_sasl(realm);
60 module:add_item("auth-provider", new_default_provider(module.host));