Software /
code /
prosody
Comparison
util/sasl.lua @ 599:30655c5cc531
Latin1 support for SASL DIGEST-MD5 (second, and possibly final commit)
author | Waqas Hussain <waqas20@gmail.com> |
---|---|
date | Mon, 08 Dec 2008 00:18:01 +0500 |
parent | 595:08ed4fa2f89d |
child | 602:a977227aa9e6 |
comparison
equal
deleted
inserted
replaced
595:08ed4fa2f89d | 599:30655c5cc531 |
---|---|
175 | 175 |
176 if not response["cnonce"] then return "failure", "malformed-request", "Missing entry for cnonce in SASL message." end | 176 if not response["cnonce"] then return "failure", "malformed-request", "Missing entry for cnonce in SASL message." end |
177 if not response["qop"] then response["qop"] = "auth" end | 177 if not response["qop"] then response["qop"] = "auth" end |
178 | 178 |
179 if response["realm"] == nil then response["realm"] = "" end | 179 if response["realm"] == nil then response["realm"] = "" end |
180 local raw_realm = response["realm"]; | 180 local decoder; |
181 | 181 |
182 if response["charset"] == nil then | 182 if response["charset"] == nil then |
183 response["username"] = latin1toutf8(response["username"]) | 183 decoder = utf8tolatin1ifpossible; |
184 response["realm"] = utf8tolatin1ifpossible(response["realm"]) | |
185 elseif response["charset"] ~= "utf-8" then | 184 elseif response["charset"] ~= "utf-8" then |
186 return "failure", "incorrect-encoding", "The client's response uses "..response["charset"].." for encoding with isn't supported by sasl.lua. Supported encodings are latin or utf-8." | 185 return "failure", "incorrect-encoding", "The client's response uses "..response["charset"].." for encoding with isn't supported by sasl.lua. Supported encodings are latin or utf-8." |
187 end | 186 end |
188 | 187 |
189 local domain = "" | 188 local domain = "" |
195 return "failure", "malformed-request", "Missing entry for digest-uri in SASL message." | 194 return "failure", "malformed-request", "Missing entry for digest-uri in SASL message." |
196 end | 195 end |
197 | 196 |
198 --TODO maybe realm support | 197 --TODO maybe realm support |
199 self.username = response["username"] | 198 self.username = response["username"] |
200 local password_encoding, Y = self.password_handler(response["username"], response["realm"], "DIGEST-MD5", raw_realm) | 199 local password_encoding, Y = self.password_handler(response["username"], response["realm"], "DIGEST-MD5", decoder) |
201 if Y == nil then return "failure", "not-authorized" | 200 if Y == nil then return "failure", "not-authorized" |
202 elseif Y == false then return "failure", "account-disabled" end | 201 elseif Y == false then return "failure", "account-disabled" end |
203 | 202 |
204 local A1 = Y..":"..response["nonce"]..":"..response["cnonce"]--:authzid | 203 local A1 = Y..":"..response["nonce"]..":"..response["cnonce"]--:authzid |
205 local A2 = "AUTHENTICATE:"..protocol.."/"..idna_ascii(domain) | 204 local A2 = "AUTHENTICATE:"..protocol.."/"..idna_ascii(domain) |