effect-auth

Abuse Protection

Compose bot, credential, email, GeoIP, and IP reputation controls explicitly.

effect-auth separates provider facts, endpoint/domain policy, and authentication decisions. Installing Turnstile, HIBP, or IPQualityScore does not silently change a flow.

Abuse controls remain replaceable while application policy owns the decision
ConcernGuidePolicy seam
Browser challengeBot ProtectionEndpoint-local request guard
Breached passwordPassword and Email RiskCredential mutation
Disposable/blocked emailPassword and Email RiskSignup and identity mutation
GeoIP/IP reputationGeoIP and IP ReputationLogin-risk engine

Bot Protection here means the provider-neutral challenge port and first-party Turnstile adapter. It does not configure Cloudflare WAF or Bot Management.

Choose a guide

Adopt only the control required by the flow; each guide keeps provider facts and product decisions separate.

Defaults are explicit

LayerBehaviorProvider required
BotProtection.noopLayerBypasses enforcementNo
BotProtectionPolicy.defaultLayerSelects SkipNo
AbuseProtection.layerNoDepsEnforces the selected bot policyBotProtectionPolicy and BotChallengeVerifier
PasswordRiskPolicy.noopLayerAccepts passwordNo
PasswordRiskPolicy.makeExplicit threshold/outage modeBreachedPasswordProvider
EmailAcceptancePolicy.noopLayerAccepts emailNo
EmailRisk.layerNoDeps(options)Applies the configured email policyEmailReputation

Do not infer strictness from a recipe name. Build and test the production policy explicitly.

Shared principles

  • Decode, validate origin, and rate-limit before remote calls where the chosen HTTP guard guarantees that order.
  • Direct domain calls and alternate transports must recreate their own request ordering.
  • Bind provider secrets through Alchemy Config.redacted; keep D1, Durable Object, and secret bindings on the private auth Worker.
  • Treat proofs, IPs, user agents, passwords, provider payloads, and API keys as sensitive transient data.
  • Persist bounded purpose-specific facts, never complete request or provider payloads.
  • Choose fail-open/closed behavior per dependency and distinguish invalid proof from retryable outage.
  • Return generic public errors; retain typed provider diagnostics only in redacted server telemetry.

For a Cloudflare signup, a practical order is: same-origin request, origin check, Durable Object rate limit, optional Turnstile, email acceptance, password risk, then atomic registration. Test short-circuiting at every stage.

Continue with Security Policies, Custom Auth API, and Testing.

On this page