blob: e917b6aa03586c5d9b49e30dc3e62ac9e18cdd53 (
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
26
27
28
29
30
31
32
33
34
35
36
|
local posix = require "posix.grp";
local pam = require "pam";
local new_sasl = require "util.sasl".new;
function user_exists(username)
for i,v in ipairs(posix.getgroup("xmpp")) do
if username == v then
return true;
end
end
return false;
end
function test_password(username, password)
local h, err = pam.start("xmpp", username, {
function (t)
if #t == 1 and t[1][1] == pam.PAM_PROMPT_ECHO_OFF then
return { { password, 0} };
end
end
});
if h and h:authenticate() and h:endx(pam.PAM_SUCCESS) then
return true, true;
end
return nil, true;
end
function get_sasl_handler()
return new_sasl(module.host, {
plain_test = function(sasl, ...)
return test_password(...)
end
});
end
module:provides"auth";
|