commit
3d4a216fff
@ -0,0 +1,16 @@ |
||||
Recaptcha.configure do |config| |
||||
# site_key and secret_key are defined via ENV already (RECAPTCHA_SITE_KEY, RECAPTCHA_SECRET_KEY) |
||||
|
||||
config.verify_url = OpenProject::Recaptcha.verify_url_override || config.verify_url |
||||
config.api_server_url = OpenProject::Recaptcha.api_server_url_override || config.api_server_url |
||||
end |
||||
|
||||
module RecaptchaLimitOverride |
||||
def invalid_response?(resp) |
||||
return super unless OpenProject::Recaptcha::use_hcaptcha? |
||||
|
||||
resp.empty? || resp.length > ::OpenProject::Recaptcha.hcaptcha_response_limit |
||||
end |
||||
end |
||||
|
||||
Recaptcha.singleton_class.prepend RecaptchaLimitOverride |
@ -0,0 +1,31 @@ |
||||
module OpenProject |
||||
module Recaptcha |
||||
module Configuration |
||||
extend self |
||||
|
||||
def use_hcaptcha? |
||||
OpenProject::Configuration['recaptcha_via_hcaptcha'] |
||||
end |
||||
|
||||
def hcaptcha_response_limit |
||||
@hcaptcha_response_limit ||= (ENV["RECAPTCHA_RESPONSE_LIMIT"].presence || 5000).to_i |
||||
end |
||||
|
||||
def api_server_url_override |
||||
ENV["RECAPTCHA_API_SERVER_URL"].presence || ((use_hcaptcha? || nil) && hcaptcha_api_server_url) |
||||
end |
||||
|
||||
def verify_url_override |
||||
ENV["RECAPTCHA_VERIFY_URL"].presence || ((use_hcaptcha? || nil) && hcaptcha_verify_url) |
||||
end |
||||
|
||||
def hcaptcha_verify_url |
||||
"https://hcaptcha.com/siteverify" |
||||
end |
||||
|
||||
def hcaptcha_api_server_url |
||||
"https://hcaptcha.com/1/api.js" |
||||
end |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue