{"id":18842678,"url":"https://github.com/dotenv-org/cloudflare_turnstile","last_synced_at":"2025-04-14T07:31:49.450Z","repository":{"id":61203345,"uuid":"549257608","full_name":"dotenv-org/cloudflare_turnstile","owner":"dotenv-org","description":"🥫 Spam protection for your Rails apps using Cloudflare Turnstile","archived":false,"fork":false,"pushed_at":"2022-10-11T00:18:23.000Z","size":38,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-09T08:17:18.705Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dotenv-org.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-10T23:18:44.000Z","updated_at":"2023-06-03T10:28:05.000Z","dependencies_parsed_at":"2022-10-12T15:36:03.835Z","dependency_job_id":null,"html_url":"https://github.com/dotenv-org/cloudflare_turnstile","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotenv-org%2Fcloudflare_turnstile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotenv-org%2Fcloudflare_turnstile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotenv-org%2Fcloudflare_turnstile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotenv-org%2Fcloudflare_turnstile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dotenv-org","download_url":"https://codeload.github.com/dotenv-org/cloudflare_turnstile/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248839435,"owners_count":21169816,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T02:55:26.914Z","updated_at":"2025-04-14T07:31:49.160Z","avatar_url":"https://github.com/dotenv-org.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cloudflare_turnstile\n\nAdd [Cloudflare Turnstile](https://blog.cloudflare.com/turnstile-private-captcha-alternative/) to your Rails app in seconds.\n\n[![Gem](https://img.shields.io/gem/v/cloudflare_turnstile.svg?style=flat-square)](https://rubygems.org/gems/cloudflare_turnstile)\n\n## Installation\n\nAdd this line to your Gemfile and then execute bundle install:\n\n```ruby\ngem \"cloudflare_turnstile\"\n```\n\n## Usage\n\nSet the following variables in your environment, .env file, or an initializer.\n\n```\nCLOUDFLARE_TURNSTILE_SITE_KEY=\"\"\nCLOUDFLARE_TURNSTILE_SECRET_KEY=\"\"\n```\n\nAdd the view helper to your form - just before the submit button is usually a good spot.\n\n```erb\n\u003c%= form_for(@user) do |f| %\u003e\n  ..\n  \u003c%= cloudflare_turnstile %\u003e\n  \u003c%= f.submit \"Log In\" %\u003e\n\u003c% end %\u003e\n```\n\nThen enable it for the controller actions you wish. It works just like a `before_action`. Pass `only:` with the action names.\n\n```ruby\nclass LoginController \u003c ApplicationController\n  cloudflare_turnstile only: [:login_submit]\n\n  def login\n  end\n\n  def login_submit\n    # Turnstile verification will take place here - prior to code. If it catches a spam bot it will halt it.\n\n    ..\n  end\nend\n```\n\nWhen catching a spam bot, it defaults to sending no content with a 200 status code. This way the spam bot will assume it was successful - tricking it.\n\n## Example\n\n![](./cloudflare_turnstile.png)\n\n## Credits\n\nInspiration [invisible_captcha](https://github.com/markets/invisible_captcha)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotenv-org%2Fcloudflare_turnstile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdotenv-org%2Fcloudflare_turnstile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotenv-org%2Fcloudflare_turnstile/lists"}