Comparison

util/sasl.lua @ 496:b3251b137d68

idna-to-unicode so password_handler looks for the right domain.
author Tobias Markmann <tm@ayena.de>
date Sun, 30 Nov 2008 01:35:40 +0100
parent 495:abc4fd4d262a
child 504:efc5184effa1
child 505:1b938e00412c
comparison
equal deleted inserted replaced
495:abc4fd4d262a 496:b3251b137d68
10 local math = require "math" 10 local math = require "math"
11 local type = type 11 local type = type
12 local error = error 12 local error = error
13 local print = print 13 local print = print
14 local idna_ascii = require "util.encodings".idna.to_ascii 14 local idna_ascii = require "util.encodings".idna.to_ascii
15 local idna_unicode = require "util.encodings".idna.to_unicode
15 16
16 module "sasl" 17 module "sasl"
17 18
18 local function new_plain(realm, password_handler) 19 local function new_plain(realm, password_handler)
19 local object = { mechanism = "PLAIN", realm = realm, password_handler = password_handler} 20 local object = { mechanism = "PLAIN", realm = realm, password_handler = password_handler}
124 return "failure", "malformed-request", "Missing entry for digest-uri in SASL message." 125 return "failure", "malformed-request", "Missing entry for digest-uri in SASL message."
125 end 126 end
126 127
127 --TODO maybe realm support 128 --TODO maybe realm support
128 self.username = response["username"] 129 self.username = response["username"]
129 local password_encoding, Y = self.password_handler(response["username"], response["realm"], "DIGEST-MD5") 130 local password_encoding, Y = self.password_handler(response["username"], idna_unicode(response["realm"]), "DIGEST-MD5")
130 if Y == nil then return "failure", "not-authorized" 131 if Y == nil then return "failure", "not-authorized"
131 elseif Y == false then return "failure", "account-disabled" end 132 elseif Y == false then return "failure", "account-disabled" end
132 133
133 local A1 = Y..":"..response["nonce"]..":"..response["cnonce"]--:authzid 134 local A1 = Y..":"..response["nonce"]..":"..response["cnonce"]--:authzid
134 local A2 = "AUTHENTICATE:"..protocol.."/"..idna_ascii(domain) 135 local A2 = "AUTHENTICATE:"..protocol.."/"..idna_ascii(domain)