Skip to content

Commit

Permalink
fix for inability to submit forms with captcha v3 in Firefox
Browse files Browse the repository at this point in the history
fix for inability to submit forms with captcha v3 in Firefox
  • Loading branch information
VladislavDimitrov authored Dec 12, 2024
2 parents 3bdbcc5 + 396d06d commit 5df33c7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
24 changes: 14 additions & 10 deletions src/captcha/README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
# Captcha widget sample

This example demonstrates how to create a captcha widget using Google reCAPTCHA v2 or Google reCAPTCHA v3.

Note: You will need to update your privacy and GDPR statements according to Google reCAPTCHA policies.

## Sitefinity setup

To start using reCAPTCHA, you need to [sign up for an API key pair](http://www.google.com/recaptcha/admin) for your site.
The keys are created for either reCAPTCHA v2 or reCAPTCHA v3 and can be used with the corresponding widget from the sample.

In order to run this sample, you need to configure the Sitefinity Web Security module. Make sure that the module is 'Active' in Administration > Modules & Services.
Note: If the Web Security module is not visible in the list of modules, you can install the Progress.Sitefinity.WebSecurity NuGet package for your current Sitefinity version.
Note: If the WebSecurity module is still not available, you can install it from Administration > Modules & Services > 'Install a module' button, with name: Web security and type: Telerik.Sitefinity.WebSecurity.WebSecurityModule, Telerik.Sitefinity.WebSecurity. You need to have the Progress.Sitefinity.WebSecurity NuGet package installed for this to work.

In order to run this sample, you must populate the captcha configuration in your Sitefinity WebSecurity config with the generated secret key. The verification URL for Google reCAPTCHA is https://www.google.com/recaptcha/api/siteverify and the response key is g-recaptcha-response.
These 3 parameters should be added in the config in thw following way:
Go to Administration > Settings > Advanced > Web Security > Captcha > Parameters and add 3 new parameters:
1. Key 'VerificationUrl' and value 'https://www.google.com/recaptcha/api/siteverify'.
2. Key 'ResponseKey' and value 'g-recaptcha-response'.
3. Key 'SecretKey' and value '<<your secret key>>'.

Once you have everything set, you should see two new widgets for forms - Captcha2 (for reCAPTCHA v2) and Captcha3 (for reCAPTCHA v3).

Once you have everything set-upped, you should see two new widgets for forms - Captcha2 (for reCAPTCHA v2) and Captcha3 (for reCAPTCHA v3).

In order for the captca widgets to work correctly on forms you will need to configure the Content Security Policy (CSP) header to allow loading the captcha scripts from the google domain. You can do that as described in the documentation: https://www.progress.com/documentation/sitefinity-cms/configure-content-security-policy-header
## The captcha widgets

In order to setup the widgets the site key must be populated in the captcha scripts - captcha2.js or captcha3.js.
In order to setup the widgets the site key must be populated in the captcha scripts - captcha2.js or captcha3.js.
2 changes: 1 addition & 1 deletion src/captcha/wwwroot/scripts/captcha3.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
if (submitButton) {
var submitId = 'onCaptchaSubmit' + i;
window[submitId] = function () {
form.dispatchEvent(new Event('submit'));
form.requestSubmit(submitButton);
};
submitButton.classList.add('g-recaptcha');
submitButton.setAttribute('data-sitekey', <Captcha V3 site key>);
Expand Down

0 comments on commit 5df33c7

Please sign in to comment.