Skip to content

Key self-host auth rate limit on the real client IP - #2053

Draft
RhysSullivan wants to merge 3 commits into
mainfrom
selfhost-auth-client-ip
Draft

RhysSullivan wants to merge 3 commits into
mainfrom
selfhost-auth-client-ip

Conversation

@RhysSullivan

@RhysSullivan RhysSullivan commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

Better Auth's rate limiter only reads the client IP from headers, so a directly exposed self-host pooled every user into one sign-in bucket (3 per 10 s).

  • The auth route now stamps the socket peer address onto x-executor-client-ip before Better Auth sees the request, always overwriting any client-supplied value. Direct deployments get per-client limiting with no configuration.
  • New EXECUTOR_TRUSTED_PROXY_HEADER + EXECUTOR_TRUSTED_PROXIES for reverse proxies (Caddy, nginx, Cloudflare). The proxy header is honoured only on connections from a listed address and stripped otherwise. Half-configured or malformed values refuse to boot.
  • Behaviour change: x-forwarded-for is no longer read on its own (any client could rotate it). A proxied instance shares one bucket until both variables are set; the server logs one warning naming them when an auth request carries a proxy-style header and no trusted proxy is configured.
  • Docs and .env.example show the proxy's own address (172.18.0.2, or its compose network) rather than a broad private range: if every hop is trusted Better Auth finds no client and falls back to one bucket. The Docker note distinguishes Linux iptables NAT (client IP preserved) from Docker Desktop and loopback traffic via the userland proxy.
  • clientIpAddressOptions builds the advanced.ipAddress block and is unit-tested; stamper tests cover the once-only warning.
  • Docs, .env.example, config tests, stamper unit tests, changeset.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 18, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
executor-marketing d486c2b Commit Preview URL

Branch Preview URL
Sep 18 2026, 07:36 PM

@github-actions

github-actions Bot commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Cloudflare preview

Console https://executor-preview-pr-2053.executor-e2e.workers.dev
MCP https://executor-preview-pr-2053.executor-e2e.workers.dev/mcp
Deployed commit d486c2b

Sign-in is Cloudflare Access (one-time PIN to an allowed email). The preview has its own database and encryption key; it is destroyed when this PR closes.

@pkg-pr-new

pkg-pr-new Bot commented Sep 18, 2026

Copy link
Copy Markdown

Open in StackBlitz

@executor-js/cli

npm i https://pkg.pr.new/@executor-js/cli@2053

@executor-js/config

npm i https://pkg.pr.new/@executor-js/config@2053

@executor-js/execution

npm i https://pkg.pr.new/@executor-js/execution@2053

@executor-js/sdk

npm i https://pkg.pr.new/@executor-js/sdk@2053

@executor-js/codemode-core

npm i https://pkg.pr.new/@executor-js/codemode-core@2053

@executor-js/runtime-quickjs

npm i https://pkg.pr.new/@executor-js/runtime-quickjs@2053

@executor-js/plugin-file-secrets

npm i https://pkg.pr.new/@executor-js/plugin-file-secrets@2053

@executor-js/plugin-graphql

npm i https://pkg.pr.new/@executor-js/plugin-graphql@2053

@executor-js/plugin-keychain

npm i https://pkg.pr.new/@executor-js/plugin-keychain@2053

@executor-js/plugin-mcp

npm i https://pkg.pr.new/@executor-js/plugin-mcp@2053

@executor-js/plugin-onepassword

npm i https://pkg.pr.new/@executor-js/plugin-onepassword@2053

@executor-js/plugin-openapi

npm i https://pkg.pr.new/@executor-js/plugin-openapi@2053

executor

npm i https://pkg.pr.new/executor@2053

commit: d486c2b

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 18, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
executor-cloud d486c2b Sep 18 2026, 07:37 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant