aboutsummaryrefslogtreecommitdiffstats
path: root/util/sasl/plain.lua
diff options
context:
space:
mode:
Diffstat (limited to 'util/sasl/plain.lua')
-rw-r--r--util/sasl/plain.lua21
1 files changed, 14 insertions, 7 deletions
diff --git a/util/sasl/plain.lua b/util/sasl/plain.lua
index d6ebe304..c9ec2911 100644
--- a/util/sasl/plain.lua
+++ b/util/sasl/plain.lua
@@ -13,9 +13,10 @@
local s_match = string.match;
local saslprep = require "util.encodings".stringprep.saslprep;
+local nodeprep = require "util.encodings".stringprep.nodeprep;
local log = require "util.logger".init("sasl");
-module "plain"
+module "sasl.plain"
-- ================================
-- SASL PLAIN according to RFC 4616
@@ -54,6 +55,14 @@ local function plain(self, message)
return "failure", "malformed-request", "Invalid username or password.";
end
+ local _nodeprep = self.profile.nodeprep;
+ if _nodeprep ~= false then
+ authentication = (_nodeprep or nodeprep)(authentication);
+ if not authentication or authentication == "" then
+ return "failure", "malformed-request", "Invalid username or password."
+ end
+ end
+
local correct, state = false, false;
if self.profile.plain then
local correct_password;
@@ -64,15 +73,13 @@ local function plain(self, message)
end
self.username = authentication
- if not state then
+ if state == false then
return "failure", "account-disabled";
- end
-
- if correct then
- return "success";
- else
+ elseif state == nil or not correct then
return "failure", "not-authorized", "Unable to authorize you with the authentication credentials you've sent.";
end
+
+ return "success";
end
function init(registerMechanism)