Skip to content

feat(platform): Add captcha to login, signup and password reset pages #9847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 26 commits into
base: dev
Choose a base branch
from

Conversation

Bentlybro
Copy link
Member

@Bentlybro Bentlybro commented Apr 21, 2025

This PR adds Cloudflare's Turnstile CAPTCHA to the login, signup, and password reset pages. it is setup to only show and work when behave as is set to CLOUD so it will not show for local hosted users.

Changes 🏗️

Backend Changes

Frontend Changes

Auth Flow Integration

  • Modified server actions in login, signup, and reset_password to accept and verify Turnstile tokens
  • Updated auth page components to integrate the CAPTCHA widget with form submissions

Configuration Changes

  • Added two new environment variables:
    • NEXT_PUBLIC_CLOUDFLARE_TURNSTILE_SITE_KEY: Public site key for frontend
    • CLOUDFLARE_TURNSTILE_SECRET_KEY: Secret key for backend verification

Test Plan 📋

  • Ask Bently for the keys to test locally!
  • Test login, signup and password reset with Turnstile enabled (BEHAVE_AS=CLOUD)
    • Verify CAPTCHA appears and must be completed before form submission
    • Verify error message appears if CAPTCHA is not completed
    • Verify form submission works after completing CAPTCHA
  • Test login, signup and password reset with Turnstile disabled (BEHAVE_AS=LOCAL)
    • Verify CAPTCHA does not appear
    • Verify form submission works without CAPTCHA
  • Test with invalid site key to ensure proper error handling

@github-project-automation github-project-automation bot moved this to 🆕 Needs initial review in AutoGPT development kanban Apr 21, 2025
@github-actions github-actions bot added platform/frontend AutoGPT Platform - Front end platform/backend AutoGPT Platform - Back end size/xl labels Apr 21, 2025
Copy link

deepsource-io bot commented Apr 21, 2025

Here's the code health analysis summary for commits afb66f7..2da4bd5. View details on DeepSource ↗.

Analysis Summary

AnalyzerStatusSummaryLink
DeepSource JavaScript LogoJavaScript✅ Success
❗ 8 occurences introduced
View Check ↗
DeepSource Python LogoPython✅ Success
❗ 7 occurences introduced
🎯 1 occurence resolved
View Check ↗

💡 If you’re a repository administrator, you can configure the quality gates from the settings.

Copy link

netlify bot commented Apr 21, 2025

Deploy Preview for auto-gpt-docs-dev canceled.

Name Link
🔨 Latest commit 2da4bd5
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs-dev/deploys/68160232c9ca820008d3d883

Copy link

netlify bot commented Apr 21, 2025

Deploy Preview for auto-gpt-docs canceled.

Name Link
🔨 Latest commit 2da4bd5
🔍 Latest deploy log https://app.netlify.com/sites/auto-gpt-docs/deploys/6816023294428100083e5244

@Bentlybro Bentlybro marked this pull request as ready for review April 21, 2025 17:10
@Bentlybro Bentlybro requested a review from a team as a code owner April 21, 2025 17:10
@Bentlybro Bentlybro requested review from Swiftyos and kcze and removed request for a team April 21, 2025 17:10
@github-actions github-actions bot added the conflicts Automatically applied to PRs with merge conflicts label Apr 22, 2025
Copy link
Contributor

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

Copy link
Contributor

Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly.

@github-actions github-actions bot removed the conflicts Automatically applied to PRs with merge conflicts label Apr 23, 2025
@Pwuts Pwuts changed the title feat(frontend + backend): Add captcha to login, signup and password reset pages feat(platform): Add captcha to login, signup and password reset pages Apr 23, 2025
@github-actions github-actions bot added the conflicts Automatically applied to PRs with merge conflicts label Apr 24, 2025
Copy link
Contributor

This pull request has conflicts with the base branch, please resolve those so we can evaluate the pull request.

Copy link
Contributor

@kcze kcze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is Turnstile configured on Cloudflare already?

@github-actions github-actions bot removed the conflicts Automatically applied to PRs with merge conflicts label Apr 28, 2025
Copy link
Contributor

Conflicts have been resolved! 🎉 A maintainer will review the pull request shortly.

@Bentlybro
Copy link
Member Author

Bentlybro commented Apr 28, 2025

@kcze

Is Turnstile configured on Cloudflare already?

yes we have turnstile setup on cloudflare, I have been using it to set up this, if you would like the info to test it locally please let me know.

Thank you for the review, I have made the changes you suggested and replied to some comments.

@Bentlybro Bentlybro requested a review from kcze April 28, 2025 14:57
@Bentlybro Bentlybro requested a review from ntindle May 2, 2025 08:17
Copy link
Contributor

@kcze kcze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this break login/signup when hosting locally? Maybe bypass verification if there's no key on the backend?
Similarly with my recommendation to require verification on login but I don't think we can skip when there's no token on the frontend because token can be changed by the user?

@Bentlybro
Copy link
Member Author

Won't this break login/signup when hosting locally? Maybe bypass verification if there's no key on the backend? Similarly with my recommendation to require verification on login but I don't think we can skip when there's no token on the frontend because this can be changed by the user?

@kcze im not sure i follow? i have been testing this locally and everything works perfectly fine with no of the turnstile keys set so it should not cause issues locally? if you have time could you test it locally to see if you have issues with signup/login? and if you want the keys to test with cloudflare let me know

@Bentlybro Bentlybro requested a review from kcze May 3, 2025 13:51
Copy link
Contributor

@kcze kcze left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested and both signup and login work locally without keys!

@github-project-automation github-project-automation bot moved this from 🚧 Needs work to 👍🏼 Mergeable in AutoGPT development kanban May 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform/backend AutoGPT Platform - Back end platform/frontend AutoGPT Platform - Front end size/xl
Projects
Status: 👍🏼 Mergeable
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants