|
@@ -29,13 +29,23 @@ function auth_password_verify(request, password)
|
|
insecure = true
|
|
insecure = true
|
|
}
|
|
}
|
|
|
|
|
|
- if c ~= 200 then
|
|
|
|
|
|
+ -- Returning PASSDB_RESULT_PASSWORD_MISMATCH will reset the user's auth cache entry.
|
|
|
|
+ -- Returning PASSDB_RESULT_INTERNAL_FAILURE keeps the existing cache entry,
|
|
|
|
+ -- even if the TTL has expired. Useful to avoid cache eviction during backend issues.
|
|
|
|
+ if c ~= 200 and c ~= 401 then
|
|
dovecot.i_info("HTTP request failed with " .. c .. " for user " .. request.user)
|
|
dovecot.i_info("HTTP request failed with " .. c .. " for user " .. request.user)
|
|
- return dovecot.auth.PASSDB_RESULT_INTERNAL_FAILURE, "Upstream error"
|
|
|
|
|
|
+ return dovecot.auth.PASSDB_RESULT_PASSWORD_MISMATCH, "Upstream error"
|
|
end
|
|
end
|
|
|
|
|
|
- local api_response = json.decode(table.concat(res))
|
|
|
|
- if api_response.success == true then
|
|
|
|
|
|
+ local response_str = table.concat(res)
|
|
|
|
+ local is_response_valid, response_json = pcall(json.decode, response_str)
|
|
|
|
+
|
|
|
|
+ if not is_response_valid then
|
|
|
|
+ dovecot.i_info("Invalid JSON received: " .. response_str)
|
|
|
|
+ return dovecot.auth.PASSDB_RESULT_PASSWORD_MISMATCH, "Invalid response format"
|
|
|
|
+ end
|
|
|
|
+
|
|
|
|
+ if response_json.success == true then
|
|
return dovecot.auth.PASSDB_RESULT_OK, ""
|
|
return dovecot.auth.PASSDB_RESULT_OK, ""
|
|
end
|
|
end
|
|
|
|
|