Software /
code /
prosody
Comparison
util/sasl/plain.lua @ 2200:dd0b250cb6c4
SASLprep authentication and password in SASL PLAIN implementation.
author | Tobias Markmann <tm@ayena.de> |
---|---|
date | Wed, 18 Nov 2009 22:02:32 +0100 |
parent | 2187:f0a85d11823e |
child | 2209:adbedc32d41b |
comparison
equal
deleted
inserted
replaced
2199:08a6b91bfe7b | 2200:dd0b250cb6c4 |
---|---|
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. | 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 -- | 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. | 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 | 13 |
14 local s_match = string.match; | 14 local s_match = string.match; |
15 local saslprep = require "util.encodings".stringprep.saslprep; | |
16 local log = require "util.logger".init("sasl"); | |
15 | 17 |
16 module "plain" | 18 module "plain" |
17 | 19 |
18 --========================= | 20 --========================= |
19 --SASL PLAIN according to RFC 4616 | 21 --SASL PLAIN according to RFC 4616 |
23 local authentication = s_match(response, "%z([^%z]+)%z") | 25 local authentication = s_match(response, "%z([^%z]+)%z") |
24 local password = s_match(response, "%z[^%z]+%z([^%z]+)") | 26 local password = s_match(response, "%z[^%z]+%z([^%z]+)") |
25 | 27 |
26 if authentication == nil or password == nil then | 28 if authentication == nil or password == nil then |
27 return "failure", "malformed-request"; | 29 return "failure", "malformed-request"; |
30 end | |
31 | |
32 -- SASLprep password and authentication | |
33 authentication = saslprep(authentication); | |
34 password = saslprep(password); | |
35 | |
36 if (not password) or (password == "") or (not authentication) or (authentication == "") then | |
37 log("debug", "Username or password violates either SASLprep."); | |
28 end | 38 end |
29 | 39 |
30 local correct, state = false, false; | 40 local correct, state = false, false; |
31 if self.profile.plain then | 41 if self.profile.plain then |
32 local correct_password; | 42 local correct_password; |