Annotate

util/sasl/anonymous.lua @ 11772:e2155e2703dd

mod_s2s: Factor out procedure for newly encrypted sessions Goal is to call this if the connection is using Direct TLS, either via multiplexing or a future Direct TLS S2S port.
author Kim Alvefur <zash@zash.se>
date Tue, 10 Aug 2021 20:51:31 +0200
parent 8874:d6eb910a204d
child 12940:2aebd9bf02fc
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
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
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
8874
d6eb910a204d util.sasl.anonymous: Shorter!
Kim Alvefur <zash@zash.se>
parents: 8873
diff changeset
15 local generate_random_id = require "util.id".medium;
2193
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
16
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 4113
diff changeset
17 local _ENV = nil;
8555
4f0f5b49bb03 vairious: Add annotation when an empty environment is set [luacheck]
Kim Alvefur <zash@zash.se>
parents: 8382
diff changeset
18 -- luacheck: std none
2193
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
19
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 --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
22
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 Supported Authentication Backends
9ce36f7eb24a util.sasl.anonymous: Adding documentation on anonymous authentication backend.
Tobias Markmann <tm@ayena.de>
parents: 2195
diff changeset
25
9ce36f7eb24a util.sasl.anonymous: Adding documentation on anonymous authentication backend.
Tobias Markmann <tm@ayena.de>
parents: 2195
diff changeset
26 anonymous:
9ce36f7eb24a util.sasl.anonymous: Adding documentation on anonymous authentication backend.
Tobias Markmann <tm@ayena.de>
parents: 2195
diff changeset
27 function(username, realm)
9ce36f7eb24a util.sasl.anonymous: Adding documentation on anonymous authentication backend.
Tobias Markmann <tm@ayena.de>
parents: 2195
diff changeset
28 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
29 end
9ce36f7eb24a util.sasl.anonymous: Adding documentation on anonymous authentication backend.
Tobias Markmann <tm@ayena.de>
parents: 2195
diff changeset
30 ]]
9ce36f7eb24a util.sasl.anonymous: Adding documentation on anonymous authentication backend.
Tobias Markmann <tm@ayena.de>
parents: 2195
diff changeset
31
8382
e5d00bf4a4d5 util: Various minor changes to please [luacheck]
Kim Alvefur <zash@zash.se>
parents: 7215
diff changeset
32 local function anonymous(self, message) -- luacheck: ignore 212/message
2193
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
33 local username;
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
34 repeat
8873
60467050bc30 util.sasl.anonymous: Generate shorter random usernames
Kim Alvefur <zash@zash.se>
parents: 8555
diff changeset
35 username = generate_random_id():lower();
3981
2b0b8fe68df2 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
36 until self.profile.anonymous(self, username, self.realm);
3155
c713fa2ba80c SASL: Minor cleanup.
Waqas Hussain <waqas20@gmail.com>
parents: 3116
diff changeset
37 self.username = username;
2193
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
38 return "success"
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
39 end
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
40
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 4113
diff changeset
41 local function init(registerMechanism)
2193
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
42 registerMechanism("ANONYMOUS", {"anonymous"}, anonymous);
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
43 end
8fbbdb11a520 Merge with sasl branch.
Tobias Markmann <tm@ayena.de>
parents:
diff changeset
44
6777
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 4113
diff changeset
45 return {
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 4113
diff changeset
46 init = init;
5de6b93d0190 util.*: Remove use of module() function, make all module functions local and return them in a table at the end
Kim Alvefur <zash@zash.se>
parents: 4113
diff changeset
47 }