tanveery / recaptcha-net

reCAPTCHA for .NET library lets you easily use Google's reCAPTCHA in an ASP.NET Web Forms / MVC / ASP.NET Core application.
Apache License 2.0
161 stars 68 forks source link

Adding RecaptchaApiSource to RecaptchaConfiguration. #61

Closed PSTDylan closed 1 year ago

PSTDylan commented 3 years ago

With these changes, one may optionally add RecaptchaApiSource to Web.config to override the default url used to fetch google's reCAPTCHA resources:

<appSettings>
    <add key="RecaptchaSiteKey" value="..." />
    <add key="RecaptchaSecretKey" value="..." />
    <add key="RecaptchaApiVersion" value="2"/>
    <add key="RecaptchaApiSource" value="www.recaptcha.net/recaptcha" />
</appSettings>

By using the above, the package will use https://www.recaptcha.net/recaptcha/api.js and https://www.recaptcha.net/recaptcha/api/siteverify rather than https://www.google.com/recaptcha/api.js and https://www.google.com/recaptcha/api/siteverify

If RecaptchaApiSource is not specified, the default is www.google.com/recaptcha.

These changes are required to allow access to users who are unable to request resources from google.com domains, as is the case for many users in China. By editing one's host file ("C:\Windows\System32\drivers\etc\hosts") to include the following, it can be tested that the reCAPTCHA widget with RecaptchaApiSource overridden works without access to google.com:

127.0.0.1 google.com www.google.com

SquareDen commented 2 years ago

Hello @tanveery! Could you please watch this PR and merge it? It is very necessary and relevant. Thanks!

PSTDylan commented 2 years ago

55 and #54 are related. I see the other solution for this was closed, but this PR allows either source.

SquareDen commented 2 years ago

55 and #54 are related. I see the other solution for this was closed, but this PR allows either source.

Yes, it would be great to solve this problem.