Repository navigation
feat(oauth-server-kit): optional Cloudflare Turnstile on the hosted sign-in form - #20
Merged
Merged
Conversation
…ign-in form
createOAuthPagesRouter takes captcha: { provider: "cloudflare-turnstile",
siteKey }. The email form renders the Turnstile widget and sends its token in
the x-captcha-response header on the send-code request, which Better Auth's
captcha plugin verifies. The token is reset after each attempt because
Turnstile tokens are single-use.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
createOAuthPagesRoutertakes an optionalcaptcha: { provider: "cloudflare-turnstile", siteKey }. When it's set, the email form on/loginand/oauth/loginrenders a Turnstile widget and sends the token in thex-captcha-responseheader when it asks for a sign-in code (/email-otp/send-verification-otp).captchaplugin on the same endpoint (documented inintegration.md).captcha, the pages are unchanged.HostedLoginCaptchais exported from/express.Why
Without a bot check, anyone can script the hosted sign-in to send codes to arbitrary addresses. SendLit needs this first.
Testing
bun testinpackages/oauth-server-kit: 113 pass. New tests cover widget rendering on both pages, refusing to submit without a token, sending the header, and the unchanged no-captcha pages. Coverage stays above the gate.check-typesand Biome are clean.captchaplugin:Product changes
Listed in the changeset (minor): pass
captchatocreateOAuthPagesRouterand add Better Auth'scaptchaplugin withendpoints: ["/email-otp/send-verification-otp"]. Configure both or neither.