Skip to content

Commit 1a6c06f

Browse files
authored
Make bot_challenge configurable (#1850)
* Disable bot_challenge * Make bot challenge configurable by env variable * Change env variable to CLOUDFLARE_CHALLENGE_ENABLED * Extract logic into own variable for cleaner reading
1 parent 9ddb676 commit 1a6c06f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

config/initializers/bot_challenge_page.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# frozen_string_literal: true
22

33
Rails.application.config.to_prepare do
4-
BotChallengePage::BotChallengePageController.bot_challenge_config.enabled = !Rails.env.test?
4+
enabled =
5+
!Rails.env.test? &&
6+
ActiveModel::Type::Boolean.new.cast(ENV.fetch('CLOUDFLARE_CHALLENGE_ENABLED', 'true'))
7+
8+
BotChallengePage::BotChallengePageController.bot_challenge_config.enabled = enabled
59

610
# Get from CloudFlare Turnstile: https://www.cloudflare.com/application-services/products/turnstile/
711
# Some testing keys are also available: https://developers.cloudflare.com/turnstile/troubleshooting/testing/

0 commit comments

Comments
 (0)