[PR #1836] [MERGED] feat: (captcha plugin) adding support for Google ReCAPTCHA v3 and hCaptcha #12268

Closed
opened 2026-04-13 08:16:47 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/1836
Author: @0scrm
Created: 3/15/2025
Status: Merged
Merged: 4/11/2025
Merged by: @Bekacru

Base: mainHead: issue-1521


📝 Commits (3)

  • 8cfbe80 feat: Adding support for HCaptcha and Google ReCAPTCHA v3
  • 687042e docs: Update captcha plugin documentation with reCAPTCHA v3 and hCaptcha
  • dc30111 fix: Restrict captcha verification to email sign-in and sign-up + updated documentation

📊 Changes

11 files changed (+510 additions, -215 deletions)

View changed files

📝 docs/content/docs/plugins/captcha.mdx (+19 -13)
📝 packages/better-auth/src/plugins/captcha/captcha.test.ts (+258 -116)
📝 packages/better-auth/src/plugins/captcha/constants.ts (+7 -1)
📝 packages/better-auth/src/plugins/captcha/error-codes.ts (+9 -3)
📝 packages/better-auth/src/plugins/captcha/index.ts (+38 -24)
📝 packages/better-auth/src/plugins/captcha/types.ts (+24 -27)
packages/better-auth/src/plugins/captcha/utils.ts (+15 -0)
📝 packages/better-auth/src/plugins/captcha/verify-handlers/cloudflare-turnstile.ts (+27 -18)
📝 packages/better-auth/src/plugins/captcha/verify-handlers/google-recaptcha.ts (+43 -12)
packages/better-auth/src/plugins/captcha/verify-handlers/h-captcha.ts (+68 -0)
📝 packages/better-auth/src/plugins/captcha/verify-handlers/index.ts (+2 -1)

📄 Description

Addresses #1521 partially: reCAPTCHA Enterprise support will come in a later PR.

Main changes:

Minor changes:

  • added the option to forward the user's IP address
  • refactor of the error handling, separating error types between external (visible to the end-user) and internal (visible in server logs) and using ctx.logger to log errors.

No breaking changes expected on existing cloudflare-turnstile and google-recaptcha (v2) providers.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/1836 **Author:** [@0scrm](https://github.com/0scrm) **Created:** 3/15/2025 **Status:** ✅ Merged **Merged:** 4/11/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `main` ← **Head:** `issue-1521` --- ### 📝 Commits (3) - [`8cfbe80`](https://github.com/better-auth/better-auth/commit/8cfbe806fa44ef98a6684b30c2ce93c99b070394) feat: Adding support for HCaptcha and Google ReCAPTCHA v3 - [`687042e`](https://github.com/better-auth/better-auth/commit/687042e4435ce1c873c224f32ec3e44b53797202) docs: Update captcha plugin documentation with reCAPTCHA v3 and hCaptcha - [`dc30111`](https://github.com/better-auth/better-auth/commit/dc30111161389c842092565b02d34660b9906e2a) fix: Restrict captcha verification to email sign-in and sign-up + updated documentation ### 📊 Changes **11 files changed** (+510 additions, -215 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/captcha.mdx` (+19 -13) 📝 `packages/better-auth/src/plugins/captcha/captcha.test.ts` (+258 -116) 📝 `packages/better-auth/src/plugins/captcha/constants.ts` (+7 -1) 📝 `packages/better-auth/src/plugins/captcha/error-codes.ts` (+9 -3) 📝 `packages/better-auth/src/plugins/captcha/index.ts` (+38 -24) 📝 `packages/better-auth/src/plugins/captcha/types.ts` (+24 -27) ➕ `packages/better-auth/src/plugins/captcha/utils.ts` (+15 -0) 📝 `packages/better-auth/src/plugins/captcha/verify-handlers/cloudflare-turnstile.ts` (+27 -18) 📝 `packages/better-auth/src/plugins/captcha/verify-handlers/google-recaptcha.ts` (+43 -12) ➕ `packages/better-auth/src/plugins/captcha/verify-handlers/h-captcha.ts` (+68 -0) 📝 `packages/better-auth/src/plugins/captcha/verify-handlers/index.ts` (+2 -1) </details> ### 📄 Description Addresses #1521 partially: reCAPTCHA Enterprise support will come in a later PR. Main changes: - support for Google Recaptcha v3 (risk score) + documentation - support for hCaptcha + documentation - fixes #1684 Minor changes: - added the option to forward the user's IP address - refactor of the error handling, separating error types between external (visible to the end-user) and internal (visible in server logs) and using `ctx.logger` to log errors. No breaking changes expected on existing `cloudflare-turnstile` and `google-recaptcha` (v2) providers. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-13 08:16:47 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#12268