aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2013-06-13 23:24:36 +0100
committerMatthew Wild <mwild1@gmail.com>2013-06-13 23:24:36 +0100
commit9052e8bf8faf0c5cf0d5f645cbe2abe8e6464817 (patch)
tree79ee0e0fb16935e5bccc66437d2064837668f111 /util
parent68036030e2d66232f23135cd6830e313be013432 (diff)
parentcd8304b6e0e62e9b917b640778580cf538b52b3c (diff)
downloadprosody-9052e8bf8faf0c5cf0d5f645cbe2abe8e6464817.tar.gz
prosody-9052e8bf8faf0c5cf0d5f645cbe2abe8e6464817.zip
Merge the merge
Diffstat (limited to 'util')
-rw-r--r--util/sasl.lua1
-rw-r--r--util/sasl/external.lua25
2 files changed, 26 insertions, 0 deletions
diff --git a/util/sasl.lua b/util/sasl.lua
index afb3861b..d0da9435 100644
--- a/util/sasl.lua
+++ b/util/sasl.lua
@@ -92,5 +92,6 @@ require "util.sasl.plain" .init(registerMechanism);
require "util.sasl.digest-md5".init(registerMechanism);
require "util.sasl.anonymous" .init(registerMechanism);
require "util.sasl.scram" .init(registerMechanism);
+require "util.sasl.external" .init(registerMechanism);
return _M;
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;