Software /
code /
prosody-modules
File
mod_auth_pam/mod_auth_pam.lua @ 1311:27b2a357c73c
mod_mam_muc: porting archive checks from mod_mam (to avoid tracebacks about calling null functions)
author | Vadim Misbakh-Soloviov <mva@mva.name> |
---|---|
date | Wed, 19 Feb 2014 18:03:39 +0700 |
parent | 1165:b8762c9fb270 |
child | 1538:57bb2497fadc |
line wrap: on
line source
-- PAM authentication for Prosody -- Copyright (C) 2013 Kim Alvefur -- -- Requires https://github.com/devurandom/lua-pam -- and LuaPosix local posix = require "posix"; local pam = require "pam"; local new_sasl = require "util.sasl".new; function user_exists(username) return not not posix.getpasswd(username); 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";