Umbraco.Forms.Issues icon indicating copy to clipboard operation
Umbraco.Forms.Issues copied to clipboard

ReCaptcha V3 not working - app settings not read

Open kspi81 opened this issue 1 year ago • 5 comments

When ReCaptcha V3 control is added to a form, and the SiteKey and PrivateKey are added to the app settings, the control still believes the app setting has not been added.

Reproduction

  • Add Recaptcha V3 with score control to a Umbraco Form
  • Generate SiteKey and PrivateKey with Google for the given domain
  • Add app settings: "Umbraco": { "CMS": { "Forms": { "FieldTypes": { "Recaptcha3": { "SiteKey": "YOUR_SITE_KEY_HERE", "PrivateKey": "YOUR_PRIVATE_KEY_HERE" } } }
  • Notice the form still generates the error message: ERROR: reCAPTCHA v3 is missing the Site Key. Please update the configuration to include a value at: Umbraco:Forms:FieldTypes:Recaptcha3:SiteKey

Specifics

Chrome Version 127.0.6533.72 Umbraco Version 14.1.0 Umbraco Forms Version 14.0.2

Expected result

Recaptcha should be generated.

Actual result

Error received: ERROR: reCAPTCHA v3 is missing the Site Key. Please update the configuration to include a value at: Umbraco:Forms:FieldTypes:Recaptcha3:SiteKey

kspi81 avatar Jul 31 '24 13:07 kspi81

I think the problem here is that you have your "Forms" configuration element as a child of the "CMS" one, which isn't correct, it should be a sibling. So for example:

"Umbraco": {
  "CMS": {
  },
  "Forms": {
    "FieldTypes": {
      "Recaptcha3": {
        "SiteKey": "YOUR_SITE_KEY_HERE",
        "PrivateKey": "YOUR_PRIVATE_KEY_HERE"
      }
    }
  }
}

AndyButland avatar Aug 01 '24 05:08 AndyButland

Hi Andy - that was my mistake when writing the ticket - the issue still stands - my forms item in app settings is indeed a sibling of CMS as it should be.

kspi81 avatar Aug 01 '24 08:08 kspi81

Hmm, I'm not seeing the issue I'm afraid on my setup, Please could you just confirm for me that the configuration is in place, by adding this code into one of the views on your website?

@inject Microsoft.Extensions.Configuration.IConfiguration Configuration
<div>Value: @Configuration["Umbraco:Forms:FieldTypes:Recaptcha3:SiteKey"]</div>

AndyButland avatar Aug 01 '24 09:08 AndyButland

I get no value from the configuration but can confirm the configuration structure is correct:

"Umbraco": { "CMS": { "ModelsBuilder": { "ModelsMode": "REDACTED" }, "Forms": { "FieldTypes": { "Recaptcha3": { "SiteKey": "REDACTED", "PrivateKey": "REDACTED" } } }, "Global": { "Id": "REDACTED", "UseHttps": REDACTED, "NoNodesViewPath": "REDACTED", "SanitizeTinyMce": REDACTED, "Smtp": { "Host": "REDACTED", "Port": REDACTED, "Username": "REDACTED", "Password": "REDACTED", "From": "REDACTED", "SecureSocketOptions": "REDACTED" } }, "Content": { "AllowEditInvariantFromNonDefault": REDACTED, "ContentVersionCleanupPolicy": { "EnableCleanup": REDACTED }, "LoginBackgroundImage": "REDACTED", "LoginLogoImage": "REDACTED" }, "Unattended": { "UpgradeUnattended": REDACTED }, "Security": { "AllowConcurrentLogins": REDACTED } } }

kspi81 avatar Aug 01 '24 09:08 kspi81

I think you need to double-check your config. It's hard to read as you are pasting it unformatted, but that is still showing Forms as a child of the CMS, not a sibling.

Here it is again having just pasted it into a formatter and removed unnecessary values so you can see what I mean:

{
   "Umbraco":{
      "CMS":{
         "ModelsBuilder":{            
         },
         "Forms":{
            "FieldTypes":{
               "Recaptcha3":{
                  "SiteKey":"REDACTED",
                  "PrivateKey":"REDACTED"
               }
            }
         },
         "Global":{            
         },
         "Content":{            
         },
         "Unattended":{            
         },
         "Security":{            
         }
      }
   }
}

It should be:

{
   "Umbraco":{
      "CMS":{
         "ModelsBuilder":{            
         },
         "Global":{            
         },
         "Content":{            
         },
         "Unattended":{            
         },
         "Security":{            
         }
      },
      "Forms":{
         "FieldTypes":{
            "Recaptcha3":{
               "SiteKey":"REDACTED",
               "PrivateKey":"REDACTED"
            }
         }
      }
   }
}

AndyButland avatar Aug 01 '24 11:08 AndyButland

Will close this now since there was no further discussion.

AndyButland avatar Aug 06 '24 10:08 AndyButland