mirror of
https://github.com/bjc/prosody.git
synced 2025-04-05 14:17:37 +03:00
Latin1 support for SASL DIGEST-MD5 (second, and possibly final commit)
This commit is contained in:
parent
0595c7a86c
commit
2e6fcdb2d0
2 changed files with 6 additions and 8 deletions
|
@ -66,15 +66,14 @@ local function handle_status(session, status)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function password_callback(node, host, mechanism, raw_host)
|
local function password_callback(node, host, mechanism, decoder)
|
||||||
log("host", host);
|
local password = (datamanager.load(node, host, "accounts") or {}).password; -- FIXME handle hashed passwords
|
||||||
log("raw_host", raw_host);
|
|
||||||
local password = (datamanager.load(node, raw_host, "accounts") or {}).password; -- FIXME handle hashed passwords
|
|
||||||
local func = function(x) return x; end;
|
local func = function(x) return x; end;
|
||||||
if password then
|
if password then
|
||||||
if mechanism == "PLAIN" then
|
if mechanism == "PLAIN" then
|
||||||
return func, password;
|
return func, password;
|
||||||
elseif mechanism == "DIGEST-MD5" then
|
elseif mechanism == "DIGEST-MD5" then
|
||||||
|
if decoder then node, host, password = decoder(node), decoder(host), decoder(password); end
|
||||||
return func, md5(node..":"..host..":"..password);
|
return func, md5(node..":"..host..":"..password);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -177,11 +177,10 @@ local function new_digest_md5(realm, password_handler)
|
||||||
if not response["qop"] then response["qop"] = "auth" end
|
if not response["qop"] then response["qop"] = "auth" end
|
||||||
|
|
||||||
if response["realm"] == nil then response["realm"] = "" end
|
if response["realm"] == nil then response["realm"] = "" end
|
||||||
local raw_realm = response["realm"];
|
local decoder;
|
||||||
|
|
||||||
if response["charset"] == nil then
|
if response["charset"] == nil then
|
||||||
response["username"] = latin1toutf8(response["username"])
|
decoder = utf8tolatin1ifpossible;
|
||||||
response["realm"] = utf8tolatin1ifpossible(response["realm"])
|
|
||||||
elseif response["charset"] ~= "utf-8" then
|
elseif response["charset"] ~= "utf-8" then
|
||||||
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."
|
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."
|
||||||
end
|
end
|
||||||
|
@ -197,7 +196,7 @@ local function new_digest_md5(realm, password_handler)
|
||||||
|
|
||||||
--TODO maybe realm support
|
--TODO maybe realm support
|
||||||
self.username = response["username"]
|
self.username = response["username"]
|
||||||
local password_encoding, Y = self.password_handler(response["username"], response["realm"], "DIGEST-MD5", raw_realm)
|
local password_encoding, Y = self.password_handler(response["username"], response["realm"], "DIGEST-MD5", decoder)
|
||||||
if Y == nil then return "failure", "not-authorized"
|
if Y == nil then return "failure", "not-authorized"
|
||||||
elseif Y == false then return "failure", "account-disabled" end
|
elseif Y == false then return "failure", "account-disabled" end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue