diff options
author | Kim Alvefur <zash@zash.se> | 2013-06-13 18:20:49 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2013-06-13 18:20:49 +0200 |
commit | e5a50872bb62aec41b74052c2f5b22fc777daca6 (patch) | |
tree | 6edb8cb27a0121e8bb7ff3194d9194ec6b058583 /util/sasl | |
parent | fdc11d1acca15a045ace62244dbb9595ec6b46f7 (diff) | |
download | prosody-e5a50872bb62aec41b74052c2f5b22fc777daca6.tar.gz prosody-e5a50872bb62aec41b74052c2f5b22fc777daca6.zip |
util.sasl.external: Add SASL EXTERNAL mechanism
Diffstat (limited to 'util/sasl')
-rw-r--r-- | util/sasl/external.lua | 25 |
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; |