iamthechad / grails3-recaptcha

ReCaptcha plugin for Grails 3
Other
3 stars 10 forks source link

Support reCAPTCHA globally #33

Open supsup opened 5 years ago

supsup commented 5 years ago

Currently in src/main/groovy/com/megatome/grails/recaptcha/ReCaptcha.groovy line 26 BASE_URL is set to: private static final String BASE_URL = "https://www.google.com/recaptcha/api"

https://developers.google.com/recaptcha/docs/faq

Can I use reCAPTCHA globally?

Yes, please use "www.recaptcha.net" in your code in circumstances when "www.google.com" is not accessible.

First, replace with After that, apply the same to everywhere else that uses "www.google.com/recaptcha/" on your site.

Request Enhancement: Make root DOMAIN a property. i.e., line 26 BASE_URL becomes: https://www.google.com becomes something like:

private static final String BASE_DOMAIN = "${grailsApplication.config.getProperty('reCaptcha.domain') ?: 'https://www.google.com'}" private static final String BASE_URL = "${BASE_DOMAIN}/recaptcha/api"

iamthechad commented 5 years ago

I had to read that FAQ entry a couple of times before I realized that "globally" meant "worldwide" in this case.

I'm not sure that a property is the way I'd like to go with this. There are only two possibilities for the domain right now (www.google.com and www.recaptcha.net), so maybe just a config flag to indicate when not to use the default value?

My concern with a config property is that anything could be injected as the base domain, and it opens up the possibility of users not knowing the correct alternate domain or entering it incorrectly.

supsup commented 5 years ago

Flag works