Comparison

util/sasl.lua @ 404:4801dbeccc2a

Some changes to report more correct SASL failures. Support for disabled accounts.
author Tobias Markmann <tm@ayena.de>
date Sun, 23 Nov 2008 21:26:06 +0100
parent 402:50f1c09541cd
child 405:62706c4e04cf
comparison
equal deleted inserted replaced
403:da92afa267cf 404:4801dbeccc2a
26 26
27 if authentication == nil or password == nil then return "failure", "malformed-request" end 27 if authentication == nil or password == nil then return "failure", "malformed-request" end
28 28
29 local password_encoding, correct_password = self.password_handler(authentication, self.realm, "PLAIN") 29 local password_encoding, correct_password = self.password_handler(authentication, self.realm, "PLAIN")
30 30
31 if correct_password == nil then return "failure", "malformed-request" end 31 if correct_password == nil then return "failure", "not-authorized" end
32 elseif correct_password == false then return "failure", "account-disabled" end
32 33
33 local claimed_password = "" 34 local claimed_password = ""
34 if password_encoding == nil then claimed_password = password 35 if password_encoding == nil then claimed_password = password
35 else claimed_password = password_encoding(password) end 36 else claimed_password = password_encoding(password) end
36 37
123 end 124 end
124 125
125 --TODO maybe realm support 126 --TODO maybe realm support
126 self.username = response["username"] 127 self.username = response["username"]
127 local password_encoding, Y = self.password_handler(response["username"], response["realm"], "DIGEST-MD5") 128 local password_encoding, Y = self.password_handler(response["username"], response["realm"], "DIGEST-MD5")
128 if Y == nil then return "failure", "malformed-request" end 129 if Y == nil then return "failure", "not-authorized" end
130 elseif Y == false then return "failure", "account-disabled" end
129 131
130 local A1 = Y..":"..response["nonce"]..":"..response["cnonce"]--:authzid 132 local A1 = Y..":"..response["nonce"]..":"..response["cnonce"]--:authzid
131 local A2 = "AUTHENTICATE:"..protocol.."/"..domain 133 local A2 = "AUTHENTICATE:"..protocol.."/"..domain
132 134
133 local HA1 = md5.sumhexa(A1) 135 local HA1 = md5.sumhexa(A1)