aboutsummaryrefslogtreecommitdiffstats
path: root/util/sasl/external.lua
blob: 4c5c4343b3b9c0aebf09ef102adf00e3d9e2455f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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;