Annotate

util/sasl/anonymous.lua @ 3093:66046a78e9c8

util.sasl.plain: Adding plain_hashed authentication backend support.
author Tobias Markmann <tm@ayena.de>
date Sun, 28 Feb 2010 22:50:25 +0100
parent 2195:8788c995fcbd
child 2992:9ce36f7eb24a
child 3094:5f625411b463
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2193
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
1 -- sasl.lua v0.4
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
2 -- Copyright (C) 2008-2009 Tobias Markmann
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
3 --
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
4 -- All rights reserved.
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
5 --
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
6 -- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
7 --
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
8 -- * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
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.
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
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.
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
11 --
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
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.
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
13
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
14 local s_match = string.match;
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
15
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
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
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
18
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
19 module "anonymous"
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
20
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
21 --=========================
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
22 --SASL ANONYMOUS according to RFC 4505
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
23 local function anonymous(self, message)
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
24 local username;
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
25 repeat
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
26 username = generate_uuid();
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
27 until self.profile.anonymous(username, self.realm);
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
28 self["username"] = username;
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
29 return "success"
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
30 end
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
31
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
32 function init(registerMechanism)
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
33 registerMechanism("ANONYMOUS", {"anonymous"}, anonymous);
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
34 end
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
35
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
36 return _M;