Skip to content

fix(auth): hermetic runs allow ten times each rate limit (#1019) - #1026

Merged
jimhoyd merged 1 commit into
mainfrom
claude/auth-hermetic-ratelimit-1019
Sep 30, 2026
Merged

jimhoyd merged 1 commit into
mainfrom
claude/auth-hermetic-ratelimit-1019

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

Fixes #1019

Problem

In a hermetic run (urlcode test, audit, benchmark, validate/routes --local-review), every fixture comes from one client address within seconds. Better Auth's limit of 10 sign-ins a minute therefore answered 429 on the eleventh sign-in, so a site whose fixtures sign in more than ten times (store-booking + store-credits merged with recipes add: 12; store-credits + store-approval: 14) could not pass urlcode test.

Design

  • betterAuthOptions now passes the limiter through rateLimitFor(rateLimit, hermetic). When AuthSettings.hermetic is true, every rule's max is multiplied by hermeticRateLimitFactor (10): the default max (100 → 1,000), every customRules entry (sign-in 10 → 100, sign-up 5 → 50, and an operator's own rules alike), and the rule a rule function returns. A rule the operator disabled (false) stays disabled.
  • This is a bounded relaxation, not a removal. The limiter stays enabled: true, storage: 'database', keyed by the admitted client address, so the rate-limit path is still exercised in hermetic runs and a fixture can still reach the 429 past the raised bound.
  • hermetic is set only by the operator host's HostContext.hermetic (RIM-EXT-HERMETIC-001), which also gives the run a throwaway database and random secret. Nothing in urlcode.yaml or the environment reaches it. serve, dev and a pinned validate activate without it and keep every limit as configured.

Tests

  • packages/auth/test/auth.test.ts: a served, non-hermetic mount answers [200 ×10, 429] on 11 sign-ins. The hermetic options are checked: served rules are unchanged, hermetic rules are ×10, operator rules and rule functions are scaled, and disabled stays disabled. A hermetic server with an operator sign-in rule of 2 still answers 429 on the 21st sign-in.
  • packages/auth/test/recipes.test.ts: authenticated-json-api with its fixtures repeated 12 times (12 sign-ins) passes urlcode test --local-review twice. It fails on main with 429.
  • packages/store/test/recipes.test.ts: store-booking + store-credits and store-credits + store-approval, merged with recipes add --project, validate, pass test twice and audit ready.
  • npm run verify and npm run test:package pass locally.

Docs

Updated the auth README and SECURITY.md, docs/READINESS.md (rate limits, test data), the RIM-EXT-HERMETIC-001 card, the auth CHANGELOG and the store-booking README.

Limitations

The factor is fixed, so a site with more than 100 fixture sign-ins a minute would still hit the limit. Nothing is reset per fixture, because core exposes no per-fixture hook to extensions.

🤖 Generated with Claude Code

…es past ten sign-ins pass (#1019)

Every fixture in a hermetic run (test, audit, benchmark, --local-review validate/routes) comes from one
client address within seconds, so Better Auth's 10 sign-ins a minute answered 429 on a site whose fixtures
sign in more than ten times (store-booking + store-credits merged: 12). An instance activated with the
operator host's hermetic flag now multiplies every rate-limit rule's max by ten (default, customRules and a
rule function's answer; a disabled rule stays disabled). The limiter stays on, database-stored and keyed by
the admitted address, so a fixture can still reach the 429. serve, dev and a pinned validate never set the
flag and keep every limit as configured; nothing in YAML or the environment can raise it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jimhoyd
jimhoyd enabled auto-merge (squash) September 30, 2026 01:12
@jimhoyd
jimhoyd merged commit 56a36c2 into main Sep 30, 2026
24 checks passed
@jimhoyd
jimhoyd deleted the claude/auth-hermetic-ratelimit-1019 branch September 30, 2026 01:18
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.

[Bug]: a site whose fixtures sign in more than ten times fails urlcode test with 429 (Better Auth rate limit in hermetic runs)

1 participant