Comparison

util/sasl/external.lua @ 5687:e879b53e9df8

util.sasl.external: Add SASL EXTERNAL mechanism
author Kim Alvefur <zash@zash.se>
date Thu, 13 Jun 2013 18:20:49 +0200
child 6777:5de6b93d0190
comparison
equal deleted inserted replaced
5686:06a49b23e5cd 5687:e879b53e9df8
1 local saslprep = require "util.encodings".stringprep.saslprep;
2
3 module "sasl.external"
4
5 local function external(self, message)
6 message = saslprep(message);
7 local state
8 self.username, state = self.profile.external(message);
9
10 if state == false then
11 return "failure", "account-disabled";
12 elseif state == nil then
13 return "failure", "not-authorized";
14 elseif state == "expired" then
15 return "false", "credentials-expired";
16 end
17
18 return "success";
19 end
20
21 function init(registerMechanism)
22 registerMechanism("EXTERNAL", {"external"}, external);
23 end
24
25 return _M;