aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-06-28 14:37:30 -0700
committerAdam Soltys <[email protected]>2026-06-28 14:37:30 -0700
commit85de6adfd6fc0f3722adf5905b82f23ed6abb11d (patch)
tree378d7efcdf4abfea120ed268eda0fb8bd5068a83 /lib
parent45e6e21024e6a8491fa07f53b931263cdeac3d8b (diff)
downloadcoinos-server-85de6adfd6fc0f3722adf5905b82f23ed6abb11d.tar.gz
coinos-server-85de6adfd6fc0f3722adf5905b82f23ed6abb11d.zip
auth: log evicted-account auth attempts with source IP
Emit a greppable EVICTED_AUTH line (username + cf-connecting-ip) when an evicted account's JWT is used, so the real-time auto-banner can block the source IP at the edge immediately rather than waiting for the hourly scan. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Diffstat (limited to 'lib')
-rw-r--r--lib/auth.ts8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/auth.ts b/lib/auth.ts
index cae73a46..b299715b 100644
--- a/lib/auth.ts
+++ b/lib/auth.ts
@@ -65,8 +65,14 @@ export const jwtStrategy = new jwt.Strategy(
user &&
((await db.sIsMember("evicted", user.id)) ||
(await db.sIsMember("evicted", user.username?.toLowerCase?.().trim())))
- )
+ ) {
+ // Distinctive, greppable line carrying the real source IP so the realtime
+ // auto-banner (scripts/atk-autoban.sh) can insta-ban it at Cloudflare.
+ console.error(
+ `EVICTED_AUTH ${user.username} ${req.headers["cf-connecting-ip"] || req.ip}`,
+ );
return next(null, false);
+ }
next(null, user);
},