diff options
Diffstat (limited to 'util/sasl')
-rw-r--r-- | util/sasl/anonymous.lua | 12 | ||||
-rw-r--r-- | util/sasl/plain.lua | 6 | ||||
-rw-r--r-- | util/sasl/scram.lua | 6 |
3 files changed, 16 insertions, 8 deletions
diff --git a/util/sasl/anonymous.lua b/util/sasl/anonymous.lua index 7b5a5081..6e6f0949 100644 --- a/util/sasl/anonymous.lua +++ b/util/sasl/anonymous.lua @@ -20,12 +20,22 @@ module "anonymous" --========================= --SASL ANONYMOUS according to RFC 4505 + +--[[ +Supported Authentication Backends + +anonymous: + function(username, realm) + return true; --for normal usage just return true; if you don't like the supplied username you can return false. + end +]] + local function anonymous(self, message) local username; repeat username = generate_uuid(); until self.profile.anonymous(username, self.realm); - self["username"] = username; + self.username = username; return "success" end diff --git a/util/sasl/plain.lua b/util/sasl/plain.lua index 39821182..1a2ba01e 100644 --- a/util/sasl/plain.lua +++ b/util/sasl/plain.lua @@ -29,7 +29,7 @@ plain: end plain_test: - function(username, realm, password) + function(username, password, realm) return true or false, state; end ]] @@ -58,9 +58,9 @@ local function plain(self, message) if self.profile.plain then local correct_password; correct_password, state = self.profile.plain(authentication, self.realm); - if correct_password == password then correct = true; else correct = false; end + correct = (correct_password == password); elseif self.profile.plain_test then - correct, state = self.profile.plain_test(authentication, self.realm, password); + correct, state = self.profile.plain_test(authentication, password, self.realm); end self.username = authentication diff --git a/util/sasl/scram.lua b/util/sasl/scram.lua index 1340423c..c366a152 100644 --- a/util/sasl/scram.lua +++ b/util/sasl/scram.lua @@ -93,10 +93,8 @@ local function validate_username(username) return username; end -local function hashprep( hashname ) - local hash = hashname:lower() - hash = hash:gsub("-", "_") - return hash +local function hashprep(hashname) + return hashname:lower():gsub("-", "_"); end function saltedPasswordSHA1(password, salt, iteration_count) |