Software /
code /
prosody
Annotate
plugins/mod_auth_anonymous.lua @ 6211:a4d26656df04
plugins/muc/muc.lib: Clean up whois handling
- adds functions `can_see_real_jids` and `get_base_presence`
- In `publicise_occupant_status`, we don't generate each type of presence until it's used
author | daurnimator <quae@daurnimator.com> |
---|---|
date | Thu, 03 Apr 2014 12:25:03 -0400 |
parent | 5370:7838acadb0fa |
child | 6023:93b4058e3320 |
rev | line source |
---|---|
3190
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
1 -- Prosody IM |
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
2 -- Copyright (C) 2008-2010 Matthew Wild |
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
3 -- Copyright (C) 2008-2010 Waqas Hussain |
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
4 -- |
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
5 -- This project is MIT/X11 licensed. Please see the |
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
6 -- COPYING file in the source package for more information. |
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
7 -- |
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
8 |
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
9 local new_sasl = require "util.sasl".new; |
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
10 local datamanager = require "util.datamanager"; |
5370
7838acadb0fa
mod_announce, mod_auth_anonymous, mod_c2s, mod_c2s, mod_component, mod_iq, mod_message, mod_presence, mod_tls: Access prosody.{hosts,bare_sessions,full_sessions} instead of the old globals
Kim Alvefur <zash@zash.se>
parents:
5229
diff
changeset
|
11 local hosts = prosody.hosts; |
3190
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
12 |
5115
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
13 -- define auth provider |
5117
2c7e1ce8f482
mod_auth_*: Use module:provides().
Waqas Hussain <waqas20@gmail.com>
parents:
5115
diff
changeset
|
14 local provider = {}; |
3190
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
15 |
5115
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
16 function provider.test_password(username, password) |
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
17 return nil, "Password based auth not supported."; |
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
18 end |
3190
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
19 |
5115
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
20 function provider.get_password(username) |
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
21 return nil, "Password not available."; |
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
22 end |
3190
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
23 |
5115
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
24 function provider.set_password(username, password) |
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
25 return nil, "Password based auth not supported."; |
3190
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
26 end |
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
27 |
5115
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
28 function provider.user_exists(username) |
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
29 return nil, "Only anonymous users are supported."; -- FIXME check if anonymous user is connected? |
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
30 end |
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
31 |
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
32 function provider.create_user(username, password) |
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
33 return nil, "Account creation/modification not supported."; |
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
34 end |
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
35 |
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
36 function provider.get_sasl_handler() |
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
37 local anonymous_authentication_profile = { |
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
38 anonymous = function(sasl, username, realm) |
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
39 return true; -- for normal usage you should always return true here |
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
40 end |
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
41 }; |
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
42 return new_sasl(module.host, anonymous_authentication_profile); |
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
43 end |
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
44 |
5229
5566236f363f
mod_auth_anonymous: Implement user iteration API
Kim Alvefur <zash@zash.se>
parents:
5117
diff
changeset
|
45 function provider.users() |
5566236f363f
mod_auth_anonymous: Implement user iteration API
Kim Alvefur <zash@zash.se>
parents:
5117
diff
changeset
|
46 return next, hosts[host].sessions, nil; |
5566236f363f
mod_auth_anonymous: Implement user iteration API
Kim Alvefur <zash@zash.se>
parents:
5117
diff
changeset
|
47 end |
5566236f363f
mod_auth_anonymous: Implement user iteration API
Kim Alvefur <zash@zash.se>
parents:
5117
diff
changeset
|
48 |
5115
3939960b3c07
mod_auth_{internal_plain,cyrus,anonymous}: Get rid of useless wrapper function new_default_provider.
Waqas Hussain <waqas20@gmail.com>
parents:
4947
diff
changeset
|
49 -- datamanager callback to disable writes |
3190
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
50 local function dm_callback(username, host, datastore, data) |
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
51 if host == module.host then |
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
52 return false; |
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
53 end |
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
54 return username, host, datastore, data; |
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
55 end |
4821
deec69fc33e5
mod_auth_anonymous: Block s2s when enabled on a host (and disallow_s2s ~= false)
Matthew Wild <mwild1@gmail.com>
parents:
4765
diff
changeset
|
56 |
4834
878f75ccc4fb
mod_s2s, mod_auth_anonymous, hostmanager: Remove disallow_s2s flag, deprecate the config option of the same name (disable mod_s2s instead), and add 'allow_anonymous_s2s' to separately control s2s for anonymous users
Matthew Wild <mwild1@gmail.com>
parents:
4821
diff
changeset
|
57 if not module:get_option_boolean("allow_anonymous_s2s", false) then |
4821
deec69fc33e5
mod_auth_anonymous: Block s2s when enabled on a host (and disallow_s2s ~= false)
Matthew Wild <mwild1@gmail.com>
parents:
4765
diff
changeset
|
58 module:hook("route/remote", function (event) |
deec69fc33e5
mod_auth_anonymous: Block s2s when enabled on a host (and disallow_s2s ~= false)
Matthew Wild <mwild1@gmail.com>
parents:
4765
diff
changeset
|
59 return false; -- Block outgoing s2s from anonymous users |
deec69fc33e5
mod_auth_anonymous: Block s2s when enabled on a host (and disallow_s2s ~= false)
Matthew Wild <mwild1@gmail.com>
parents:
4765
diff
changeset
|
60 end, 300); |
deec69fc33e5
mod_auth_anonymous: Block s2s when enabled on a host (and disallow_s2s ~= false)
Matthew Wild <mwild1@gmail.com>
parents:
4765
diff
changeset
|
61 end |
deec69fc33e5
mod_auth_anonymous: Block s2s when enabled on a host (and disallow_s2s ~= false)
Matthew Wild <mwild1@gmail.com>
parents:
4765
diff
changeset
|
62 |
3190
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
63 function module.load() |
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
64 datamanager.add_callback(dm_callback); |
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
65 end |
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
66 function module.unload() |
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
67 datamanager.remove_callback(dm_callback); |
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
68 end |
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
69 |
5117
2c7e1ce8f482
mod_auth_*: Use module:provides().
Waqas Hussain <waqas20@gmail.com>
parents:
5115
diff
changeset
|
70 module:provides("auth", provider); |
3190
c4069680a01c
mod_auth_anonymous: Auth provider with support for SASL ANONYMOUS.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
71 |