Software /
code /
prosody
Comparison
util/sasl.lua @ 1722:132c41aa0680
Change variable name. The previous choice was too ugly looking.
author | Tobias Markmann <tm@ayena.de> |
---|---|
date | Wed, 19 Aug 2009 22:04:14 +0200 |
parent | 1720:c34409a5fdee |
child | 1723:2145daff1a65 |
comparison
equal
deleted
inserted
replaced
1721:1dcfb2c64302 | 1722:132c41aa0680 |
---|---|
18 local st = require "util.stanza"; | 18 local st = require "util.stanza"; |
19 local generate_uuid = require "util.uuid".generate; | 19 local generate_uuid = require "util.uuid".generate; |
20 local t_insert, t_concat = table.insert, table.concat; | 20 local t_insert, t_concat = table.insert, table.concat; |
21 local to_byte, to_char = string.byte, string.char; | 21 local to_byte, to_char = string.byte, string.char; |
22 local to_unicode = require "util.encodings".idna.to_unicode; | 22 local to_unicode = require "util.encodings".idna.to_unicode; |
23 local u_e_saslprep = require "utii.encodings".stringprep.saslprep; | 23 local saslprep = require "utii.encodings".stringprep.saslprep; |
24 local s_match = string.match; | 24 local s_match = string.match; |
25 local gmatch = string.gmatch | 25 local gmatch = string.gmatch |
26 local string = string | 26 local string = string |
27 local math = require "math" | 27 local math = require "math" |
28 local type = type | 28 local type = type |
38 if message == "" or message == nil then return "failure", "malformed-request" end | 38 if message == "" or message == nil then return "failure", "malformed-request" end |
39 local response = message | 39 local response = message |
40 local authorization = s_match(response, "([^&%z]+)") | 40 local authorization = s_match(response, "([^&%z]+)") |
41 local authentication = s_match(response, "%z([^&%z]+)%z") | 41 local authentication = s_match(response, "%z([^&%z]+)%z") |
42 local password = s_match(response, "%z[^&%z]+%z([^&%z]+)") | 42 local password = s_match(response, "%z[^&%z]+%z([^&%z]+)") |
43 authorization, authentication, password = u_e_saslprep(authorization), u_e_saslprep(authentication), u_e_saslprep(password); | 43 authorization, authentication, password = saslprep(authorization), saslprep(authentication), saslprep(password); |
44 | 44 |
45 if authentication == nil or password == nil then return "failure", "malformed-request" end | 45 if authentication == nil or password == nil then return "failure", "malformed-request" end |
46 | 46 |
47 local password_encoding, correct_password = self.password_handler(authentication, self.realm, self.realm, "PLAIN") | 47 local password_encoding, correct_password = self.password_handler(authentication, self.realm, self.realm, "PLAIN") |
48 | 48 |
50 elseif correct_password == false then return "failure", "account-disabled" end | 50 elseif correct_password == false then return "failure", "account-disabled" end |
51 | 51 |
52 local claimed_password = "" | 52 local claimed_password = "" |
53 if password_encoding == nil then claimed_password = password | 53 if password_encoding == nil then claimed_password = password |
54 else claimed_password = password_encoding(password) end | 54 else claimed_password = password_encoding(password) end |
55 caimed_password = u_e_saslprep(claimed_password); | 55 caimed_password = saslprep(claimed_password); |
56 | 56 |
57 self.username = authentication | 57 self.username = authentication |
58 if claimed_password == correct_password then | 58 if claimed_password == correct_password then |
59 return "success" | 59 return "success" |
60 else | 60 else |