aboutsummaryrefslogtreecommitdiffstats
path: root/util/sasl/external.lua
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
commiteb2837ec6dda62615b65af213847abaf859d752a (patch)
tree79ee0e0fb16935e5bccc66437d2064837668f111 /util/sasl/external.lua
parentff224e953c0e4ca7ed515d59afb1f0d8db06298d (diff)
parentee47583ffba1c0c823afbc0943951617356800e6 (diff)
downloadprosody-eb2837ec6dda62615b65af213847abaf859d752a.tar.gz
prosody-eb2837ec6dda62615b65af213847abaf859d752a.zip
Merge the merge
Diffstat (limited to 'util/sasl/external.lua')
-rw-r--r--util/sasl/external.lua25
1 files changed, 25 insertions, 0 deletions
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;