1
0
mirror of https://github.com/mailcow/mailcow-dockerized.git synced 2025-12-13 01:45:59 +00:00

[Dovecot] Increase Timeout for HTTP Login Request

This commit is contained in:
FreddleSpl0it
2025-03-27 16:52:15 +01:00
parent 1c9d80f554
commit 4ad2422810

View File

@@ -3,10 +3,10 @@ function auth_password_verify(request, password)
return dovecot.auth.PASSDB_RESULT_USER_UNKNOWN, "No such user" return dovecot.auth.PASSDB_RESULT_USER_UNKNOWN, "No such user"
end end
json = require "cjson" local json = require "cjson"
ltn12 = require "ltn12" local ltn12 = require "ltn12"
https = require "ssl.https" local https = require "ssl.https"
https.TIMEOUT = 5 https.TIMEOUT = 30
local req = { local req = {
username = request.user, username = request.user,
@@ -16,8 +16,7 @@ function auth_password_verify(request, password)
} }
req.protocol[request.service] = true req.protocol[request.service] = true
local req_json = json.encode(req) local req_json = json.encode(req)
local res = {} local res = {}
local b, c = https.request { local b, c = https.request {
method = "POST", method = "POST",
url = "https://nginx:9082", url = "https://nginx:9082",
@@ -29,11 +28,16 @@ function auth_password_verify(request, password)
sink = ltn12.sink.table(res), sink = ltn12.sink.table(res),
insecure = true insecure = true
} }
if c ~= 200 then
dovecot.i_info("HTTP request failed with " .. c .. " for user " .. request.user)
return dovecot.auth.PASSDB_RESULT_INTERNAL_FAILURE, "Upstream error"
end
local api_response = json.decode(table.concat(res)) local api_response = json.decode(table.concat(res))
if api_response.success == true then if api_response.success == true then
return dovecot.auth.PASSDB_RESULT_OK, "" return dovecot.auth.PASSDB_RESULT_OK, ""
end end
return dovecot.auth.PASSDB_RESULT_PASSWORD_MISMATCH, "Failed to authenticate" return dovecot.auth.PASSDB_RESULT_PASSWORD_MISMATCH, "Failed to authenticate"
end end