From 216b3a3df35f3631e0955870c2e97ac466e064ed Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 13 Jun 2013 18:20:49 +0200 Subject: util.sasl.external: Add SASL EXTERNAL mechanism --- util/sasl/external.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 util/sasl/external.lua (limited to 'util/sasl/external.lua') diff --git a/util/sasl/external.lua b/util/sasl/external.lua new file mode 100644 index 00000000..4c5c4343 --- /dev/null +++ b/util/sasl/external.lua @@ -0,0 +1,25 @@ +local saslprep = require "util.encodings".stringprep.saslprep; + +module "sasl.external" + +local function external(self, message) + message = saslprep(message); + local state + self.username, state = self.profile.external(message); + + if state == false then + return "failure", "account-disabled"; + elseif state == nil then + return "failure", "not-authorized"; + elseif state == "expired" then + return "false", "credentials-expired"; + end + + return "success"; +end + +function init(registerMechanism) + registerMechanism("EXTERNAL", {"external"}, external); +end + +return _M; -- cgit v1.2.3