Software /
code /
prosody
Annotate
util/sasl/anonymous.lua @ 6539:f923140ee7c5
net.server_select: Fix timers not being fired until another timer fixes (or 1 second passes)
author | daurnimator <quae@daurnimator.com> |
---|---|
date | Thu, 15 Jan 2015 09:03:00 -0500 |
parent | 4113:65482a852c4d |
child | 6777:5de6b93d0190 |
rev | line source |
---|---|
2193 | 1 -- sasl.lua v0.4 |
3094
5f625411b463
util.sasl: 2009 -> 2010 in copyright header.
Tobias Markmann <tm@ayena.de>
parents:
2195
diff
changeset
|
2 -- Copyright (C) 2008-2010 Tobias Markmann |
2193 | 3 -- |
4 -- All rights reserved. | |
5 -- | |
6 -- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | |
7 -- | |
8 -- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | |
9 -- * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | |
10 -- * Neither the name of Tobias Markmann nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. | |
11 -- | |
12 -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
13 | |
14 local s_match = string.match; | |
15 | |
16 local log = require "util.logger".init("sasl"); | |
2195
8788c995fcbd
Added missing require for generate_uuid.
Tobias Markmann <tm@ayena.de>
parents:
2193
diff
changeset
|
17 local generate_uuid = require "util.uuid".generate; |
2193 | 18 |
4113
65482a852c4d
util.sasl.*: Add 'sasl.' prefix to module names
Matthew Wild <mwild1@gmail.com>
parents:
4049
diff
changeset
|
19 module "sasl.anonymous" |
2193 | 20 |
21 --========================= | |
22 --SASL ANONYMOUS according to RFC 4505 | |
2992
9ce36f7eb24a
util.sasl.anonymous: Adding documentation on anonymous authentication backend.
Tobias Markmann <tm@ayena.de>
parents:
2195
diff
changeset
|
23 |
9ce36f7eb24a
util.sasl.anonymous: Adding documentation on anonymous authentication backend.
Tobias Markmann <tm@ayena.de>
parents:
2195
diff
changeset
|
24 --[[ |
9ce36f7eb24a
util.sasl.anonymous: Adding documentation on anonymous authentication backend.
Tobias Markmann <tm@ayena.de>
parents:
2195
diff
changeset
|
25 Supported Authentication Backends |
9ce36f7eb24a
util.sasl.anonymous: Adding documentation on anonymous authentication backend.
Tobias Markmann <tm@ayena.de>
parents:
2195
diff
changeset
|
26 |
9ce36f7eb24a
util.sasl.anonymous: Adding documentation on anonymous authentication backend.
Tobias Markmann <tm@ayena.de>
parents:
2195
diff
changeset
|
27 anonymous: |
9ce36f7eb24a
util.sasl.anonymous: Adding documentation on anonymous authentication backend.
Tobias Markmann <tm@ayena.de>
parents:
2195
diff
changeset
|
28 function(username, realm) |
9ce36f7eb24a
util.sasl.anonymous: Adding documentation on anonymous authentication backend.
Tobias Markmann <tm@ayena.de>
parents:
2195
diff
changeset
|
29 return true; --for normal usage just return true; if you don't like the supplied username you can return false. |
9ce36f7eb24a
util.sasl.anonymous: Adding documentation on anonymous authentication backend.
Tobias Markmann <tm@ayena.de>
parents:
2195
diff
changeset
|
30 end |
9ce36f7eb24a
util.sasl.anonymous: Adding documentation on anonymous authentication backend.
Tobias Markmann <tm@ayena.de>
parents:
2195
diff
changeset
|
31 ]] |
9ce36f7eb24a
util.sasl.anonymous: Adding documentation on anonymous authentication backend.
Tobias Markmann <tm@ayena.de>
parents:
2195
diff
changeset
|
32 |
2193 | 33 local function anonymous(self, message) |
34 local username; | |
35 repeat | |
36 username = generate_uuid(); | |
4049
fe6f4a255fd8
util.sasl.*, mod_auth_*, mod_saslauth: Pass SASL handler as first parameter to SASL profile callbacks.
Waqas Hussain <waqas20@gmail.com>
parents:
3155
diff
changeset
|
37 until self.profile.anonymous(self, username, self.realm); |
3155 | 38 self.username = username; |
2193 | 39 return "success" |
40 end | |
41 | |
42 function init(registerMechanism) | |
43 registerMechanism("ANONYMOUS", {"anonymous"}, anonymous); | |
44 end | |
45 | |
4113
65482a852c4d
util.sasl.*: Add 'sasl.' prefix to module names
Matthew Wild <mwild1@gmail.com>
parents:
4049
diff
changeset
|
46 return _M; |