Fix passkey login 429 by forwarding client IPs correctly.

Forward X-Forwarded-For through frontend nginx, use TRUST_PROXY=1 for the Docker hop, and limit auth rate limiting to login flows only.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-02 22:48:15 +02:00
co-authored by Cursor
parent 2156aa4bbd
commit 2b029a26f0
5 changed files with 28 additions and 7 deletions
+18 -1
View File
@@ -45,6 +45,18 @@ export function createApp(): express.Express {
app.use(cookieParser())
app.use(express.json({ limit: '50mb' }))
/** Passkey login/register only — not person-pool, profile, etc. */
const authFlowPaths = new Set([
'/register-options',
'/register-verify',
'/login-options',
'/login-verify',
'/reauth-options',
'/reauth-verify',
'/logout',
'/session'
])
const authLimiter = rateLimit({
windowMs: 15 * 60 * 1000,
max: 60,
@@ -66,7 +78,12 @@ export function createApp(): express.Express {
legacyHeaders: false
})
app.use('/api/auth', authLimiter)
app.use('/api/auth', (req, res, next) => {
if (authFlowPaths.has(req.path)) {
return authLimiter(req, res, next)
}
return next()
})
app.use('/api/collaboration/invite-details', publicCollaborationLimiter)
app.use('/api/collaboration/share-pull', publicCollaborationLimiter)
app.use('/api', apiLimiter)