fix: check trusted proxy login against nginx's peer, not nginx (#1625)

The backend only sees the bundled nginx on loopback, so the allowlist
could only work by trusting 127.0.0.1, which let any client that reached
nginx log in as anyone by sending the identity headers. nginx now passes
its own TCP peer (before real_ip rewriting) in X-Termix-Proxy-Peer, and
loopback connections are judged by that address instead.
This commit is contained in:
ZacharyZcR authored and GitHub committed 2026-10-14 08:12:58 +08:00
1 parent 8c3f816407
commit 872e5eba73
6 files changed
+69 -2

No files matched your search

+2 -1
View File
@@ -44,6 +44,7 @@ import {
import type { UserRecord } from "../repositories/user-repository.js";
import {
getTrustedProxyAuthConfig,
getTrustedProxySourceAddress,
isTrustedProxyAddress,
isTrustedProxyAuthEnabled,
resolveTrustedProxyRoles,
@@ -304,7 +305,7 @@ router.post("/proxy-login", async (req, res) => {
}
if (!config.enabled) return res.json({ enabled: false });
const sourceAddress = req.socket.remoteAddress;
const sourceAddress = getTrustedProxySourceAddress(req);
try {
if (!isTrustedProxyAddress(sourceAddress, config.trustedProxies)) {
authLogger.warn(