Software /
code /
prosody
Annotate
plugins/mod_auth_cyrus.lua @ 3450:4bd78a5fee75
mod_bosh: Fix to properly ignore repeated requests
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 07 Aug 2010 19:00:04 +0100 |
parent | 3425:26751c628207 |
child | 3468:d50e2c937717 |
rev | line source |
---|---|
3192
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
1 -- Prosody IM |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
2 -- Copyright (C) 2008-2010 Matthew Wild |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
3 -- Copyright (C) 2008-2010 Waqas Hussain |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
4 -- |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
5 -- This project is MIT/X11 licensed. Please see the |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
6 -- COPYING file in the source package for more information. |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
7 -- |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
8 |
3271
1b6c2984c1f4
mod_auth_cyrus: Log as "auth_cyrus", not as "usermanager".
Waqas Hussain <waqas20@gmail.com>
parents:
3192
diff
changeset
|
9 local log = require "util.logger".init("auth_cyrus"); |
3192
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
10 |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
11 local cyrus_service_realm = module:get_option("cyrus_service_realm"); |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
12 local cyrus_service_name = module:get_option("cyrus_service_name"); |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
13 local cyrus_application_name = module:get_option("cyrus_application_name"); |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
14 |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
15 prosody.unlock_globals(); --FIXME: Figure out why this is needed and |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
16 -- why cyrussasl isn't caught by the sandbox |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
17 local cyrus_new = require "util.sasl_cyrus".new; |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
18 prosody.lock_globals(); |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
19 local new_sasl = function(realm) |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
20 return cyrus_new( |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
21 cyrus_service_realm or realm, |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
22 cyrus_service_name or "xmpp", |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
23 cyrus_application_name or "prosody" |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
24 ); |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
25 end |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
26 |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
27 function new_default_provider(host) |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
28 local provider = { name = "cyrus" }; |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
29 log("debug", "initializing default authentication provider for host '%s'", host); |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
30 |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
31 function provider.test_password(username, password) |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
32 return nil, "Legacy auth not supported with Cyrus SASL."; |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
33 end |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
34 |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
35 function provider.get_password(username) |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
36 return nil, "Passwords unavailable for Cyrus SASL."; |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
37 end |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
38 |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
39 function provider.set_password(username, password) |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
40 return nil, "Passwords unavailable for Cyrus SASL."; |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
41 end |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
42 |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
43 function provider.user_exists(username) |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
44 return true; |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
45 end |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
46 |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
47 function provider.create_user(username, password) |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
48 return nil, "Account creation/modification not available with Cyrus SASL."; |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
49 end |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
50 |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
51 function provider.get_sasl_handler() |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
52 local realm = module:get_option("sasl_realm") or module.host; |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
53 return new_sasl(realm); |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
54 end |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
55 |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
56 return provider; |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
57 end |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
58 |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
59 module:add_item("auth-provider", new_default_provider(module.host)); |
8ad50989d79e
mod_auth_cyrus: Auth provider with support for Cyrus SASL.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
60 |