restarone / violet_rails

an app engine for your business. Seamlessly implement business logic with a powerful API. Out of the box CMS, blog, forum and email functionality. Developer friendly & easily extendable for your next SaaS/XaaS project. Built with Rails 6, Devise, Sidekiq & PostgreSQL
https://violet.restarone.solutions
MIT License
96 stars 44 forks source link

recaptcha V2 & V3: Documentation, Usage and Examples #734

Open donrestarone opened 2 years ago

donrestarone commented 2 years ago

Before you begin

Recaptcha is a proprietary technology developed by Google. Recaptcha's client-side code is neutrally included as part of Violet Rails to implement Recaptcha challenges on a per-application basis. Before use please see Google's privacy: https://policies.google.com/privacy and Terms of Service: https://policies.google.com/terms

I don't like the default Recaptcha branding on the API Form, can I change it?

Google has some specific rules, we will yield to them on this matter hiding recaptch badge

Google Recaptcha Console setup

Login to the recaptcha console Screenshot from 2022-06-12 12-04-58

Register your site:

Screenshot from 2022-06-12 12-05-37

Server configuration: Violet Rails supports V2 and V3

Recaptcha V2

Renders a challenge like so: Screenshot from 2022-06-12 12-39-40

Env Variables

Ensure that the following variables are set in .rbenv-vars / Heroku / Where-ever you set environment variables for your system RECAPTCHA_SITE_KEY=6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy RECAPTCHA_SECRET_KEY=6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx

Recaptcha V3

Does not render a challenge, but observes how the form is filled out and decides automatically if its a bot or human that completed the web form Screenshot from 2022-06-12 12-38-50

Env Variables

Ensure that the following variables are set in .rbenv-vars / Heroku / Where-ever you set environment variables for your system RECAPTCHA_SITE_KEY_V3=6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy RECAPTCHA_SECRET_KEY_V3=6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx

After setting the environment, restart the system-- eg:

sudo systemctl restart puma.service
sudo systemctl restart sidekiq.service

Violet Rails Client Setup

Simply choose which version of Recaptcha you want Violet Rails to render: Screenshot from 2022-06-12 18-53-47

donrestarone commented 2 years ago

@alis-khadka can you link me to the document that says that we need to show some Google branding/privacy policy/TOS copy when we use recaptcha v3?

alis-khadka commented 2 years ago

@alis-khadka can you link me to the document that says that we need to show some Google branding/privacy policy/TOS copy when we use recaptcha v3?

You mean in case of hiding the recaptcha badge, right? hiding recaptch badge

donrestarone commented 2 years ago

@alis-khadka yup, That's the one, thanks!