mirror of
https://github.com/chatmail/relay.git
synced 2026-05-21 05:18:04 +00:00
wip
This commit is contained in:
@@ -8,7 +8,6 @@ end
|
|||||||
-- call out to python program to actually manage authentication for dovecot
|
-- call out to python program to actually manage authentication for dovecot
|
||||||
|
|
||||||
function chatctl_verify(user, password)
|
function chatctl_verify(user, password)
|
||||||
dovecot.i_debug("chatctl_verify wurde aufgerufen")
|
|
||||||
local handle = io.popen("python3 /home/vmail/chatctl hexauth "..escape(user).." "..escape(password))
|
local handle = io.popen("python3 /home/vmail/chatctl hexauth "..escape(user).." "..escape(password))
|
||||||
local result = handle:read("*a")
|
local result = handle:read("*a")
|
||||||
handle:close()
|
handle:close()
|
||||||
@@ -30,7 +29,7 @@ end
|
|||||||
|
|
||||||
function auth_password_verify(request, password)
|
function auth_password_verify(request, password)
|
||||||
local res = chatctl_verify(request.user, password)
|
local res = chatctl_verify(request.user, password)
|
||||||
request:log_error("auth_password_verify "..request.user.." "..password)
|
-- request:log_error("auth_password_verify "..request.user.." "..password)
|
||||||
if res.status == "ok" then
|
if res.status == "ok" then
|
||||||
local extra = get_extra_dovecot_output(res)
|
local extra = get_extra_dovecot_output(res)
|
||||||
return dovecot.auth.PASSDB_RESULT_OK, get_extra_dovecot_output(res)
|
return dovecot.auth.PASSDB_RESULT_OK, get_extra_dovecot_output(res)
|
||||||
@@ -41,8 +40,6 @@ end
|
|||||||
|
|
||||||
function auth_userdb_lookup(request)
|
function auth_userdb_lookup(request)
|
||||||
local res = chatctl_lookup(request.user)
|
local res = chatctl_lookup(request.user)
|
||||||
dovecot.i_debug("auth_userdb_lookup")
|
|
||||||
|
|
||||||
if res.status == "ok" then
|
if res.status == "ok" then
|
||||||
return dovecot.auth.USERDB_RESULT_OK, get_extra_dovecot_output(res)
|
return dovecot.auth.USERDB_RESULT_OK, get_extra_dovecot_output(res)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import sys
|
|||||||
def get_user_data(user):
|
def get_user_data(user):
|
||||||
if user == b"link2xt@c1.testrun.org":
|
if user == b"link2xt@c1.testrun.org":
|
||||||
return dict(
|
return dict(
|
||||||
home="/home/vmail/link2xt",
|
|
||||||
uid="vmail",
|
uid="vmail",
|
||||||
gid="vmail",
|
gid="vmail",
|
||||||
password=b"Ahyei6ie",
|
password=b"Ahyei6ie",
|
||||||
|
|||||||
@@ -15,19 +15,19 @@ dovecot = {
|
|||||||
|
|
||||||
-- Tests for testing the lua<->python interaction
|
-- Tests for testing the lua<->python interaction
|
||||||
|
|
||||||
function test_passdb_verify_ok(user, password)
|
function test_password_verify_ok(user, password)
|
||||||
local res, extra = auth_passdb_verify({user=user}, password)
|
local res, extra = auth_password_verify({user=user}, password)
|
||||||
assert(res==dovecot.auth.PASSDB_RESULT_OK)
|
assert(res==dovecot.auth.PASSDB_RESULT_OK)
|
||||||
assert(extra.uid == "vmail")
|
assert(extra.uid == "vmail")
|
||||||
assert(extra.gid == "vmail")
|
assert(extra.gid == "vmail")
|
||||||
-- assert(extra.homedir == "/home/vmail/link2xt")
|
-- assert(extra.homedir == "/home/vmail/link2xt")
|
||||||
print("OK test_passdb_verify_ok "..user.." "..password)
|
print("OK test_password_verify_ok "..user.." "..password)
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_passdb_verify_mismatch(user, password)
|
function test_password_verify_mismatch(user, password)
|
||||||
local res = auth_passdb_verify({user=user}, password)
|
local res = auth_password_verify({user=user}, password)
|
||||||
assert(res == dovecot.auth.PASSDB_RESULT_PASSWORD_MISMATCH)
|
assert(res == dovecot.auth.PASSDB_RESULT_PASSWORD_MISMATCH)
|
||||||
print("OK test_passdb_verify_mismatch "..user.." "..password)
|
print("OK test_password_verify_mismatch "..user.." "..password)
|
||||||
end
|
end
|
||||||
|
|
||||||
function test_userdb_lookup_ok(user)
|
function test_userdb_lookup_ok(user)
|
||||||
@@ -67,8 +67,8 @@ function test_split_chatctl()
|
|||||||
end
|
end
|
||||||
|
|
||||||
test_split_chatctl()
|
test_split_chatctl()
|
||||||
test_passdb_verify_ok("link2xt@instant2.testrun.org", "Ahyei6ie")
|
test_password_verify_ok("link2xt@instant2.testrun.org", "Ahyei6ie")
|
||||||
test_passdb_verify_mismatch("link2xt@instant2.testrun.org", "Aqwlek")
|
test_password_verify_mismatch("link2xt@instant2.testrun.org", "Aqwlek")
|
||||||
test_userdb_lookup_ok("link2xt@instant2.testrun.org")
|
test_userdb_lookup_ok("link2xt@instant2.testrun.org")
|
||||||
test_userdb_lookup_mismatch("wlekqjlew@xyz.org")
|
test_userdb_lookup_mismatch("wlekqjlew@xyz.org")
|
||||||
test_passdb_lookup_ok("link2xt@instant2.testrun.org")
|
test_passdb_lookup_ok("link2xt@instant2.testrun.org")
|
||||||
|
|||||||
Reference in New Issue
Block a user