From f6ed180945431780b457b944e92b1cc4a76dd798 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Thu, 26 Aug 2021 14:02:01 +0200 Subject: [PATCH] TT#137602 auth_sql: lower domain for comparation * prosody keeps host using nameprep Change-Id: I04c8cffdb46f33fe932b64e1ab1f9fcc49febb00 (cherry picked from commit a7e1cd53fbbdb5c52a0eaa218846601526bb281e) --- debian/patches/mod_auth_sql.path | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/debian/patches/mod_auth_sql.path b/debian/patches/mod_auth_sql.path index d409ffa..6c0241a 100644 --- a/debian/patches/mod_auth_sql.path +++ b/debian/patches/mod_auth_sql.path @@ -7,7 +7,7 @@ Subject: sipwise custom auth 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/mod_auth_sql/mod_auth_sql.lua b/plugins/mod_auth_sql/mod_auth_sql.lua -index 2947a91..237ad28 100644 +index 2947a91..631768d 100644 --- a/plugins/mod_auth_sql/mod_auth_sql.lua +++ b/plugins/mod_auth_sql/mod_auth_sql.lua @@ -71,10 +71,13 @@ local function getsql(sql, ...) @@ -15,7 +15,7 @@ index 2947a91..237ad28 100644 local function get_password(username) - local stmt, err = getsql("SELECT `password` FROM `authreg` WHERE `username`=? AND `realm`=?", username, module.host); -+ local stmt, err = getsql("SELECT `s`.`password`, COALESCE(`p`.`value`, 0) AS `locklevel` FROM `subscriber` AS `s` LEFT JOIN usr_preferences AS `p` ON `p`.`username` = `s`.`username` AND `p`.`domain` = `s`.`domain` AND `p`.`attribute` = 'lock' WHERE `s`.`username`= ? AND `s`.`domain`= ?", username, module.host); ++ local stmt, err = getsql("SELECT `s`.`password`, COALESCE(`p`.`value`, 0) AS `locklevel` FROM `subscriber` AS `s` LEFT JOIN usr_preferences AS `p` ON `p`.`username` = `s`.`username` AND `p`.`domain` = `s`.`domain` AND `p`.`attribute` = 'lock' WHERE `s`.`username`= ? AND lower(`s`.`domain`)= ?", username, module.host); if stmt then for row in stmt:rows(true) do - return row.password; @@ -31,7 +31,7 @@ index 2947a91..237ad28 100644 function provider.users() - local stmt, err = getsql("SELECT `username` FROM `authreg` WHERE `realm`=?", module.host); -+ local stmt, err = getsql("SELECT `username` FROM `subscriber` WHERE `domain`=?", module.host); ++ local stmt, err = getsql("SELECT `username` FROM `subscriber` WHERE lower(`domain`)=?", module.host); if stmt then local next, state = stmt:rows(true) return function()