Commit 7c6e3d01 authored by Stan Hu's avatar Stan Hu

Only override default if Omnibus protected paths is not enabled

parent ea66022b
...@@ -13,12 +13,26 @@ class ChangeDefaultValueOfThrottleProtectedPaths < ActiveRecord::Migration[5.2] ...@@ -13,12 +13,26 @@ class ChangeDefaultValueOfThrottleProtectedPaths < ActiveRecord::Migration[5.2]
# 12.4. This migration toggles it back off to ensure we don't # 12.4. This migration toggles it back off to ensure we don't
# inadvertently block legitimate users. The admin will have to # inadvertently block legitimate users. The admin will have to
# re-enable it in the application settings. # re-enable it in the application settings.
unless omnibus_protected_paths_present?
execute "UPDATE application_settings SET throttle_protected_paths_enabled = #{false_value}" execute "UPDATE application_settings SET throttle_protected_paths_enabled = #{false_value}"
end end
end
def down def down
change_column_default :application_settings, :throttle_protected_paths_enabled, true change_column_default :application_settings, :throttle_protected_paths_enabled, true
execute "UPDATE application_settings SET throttle_protected_paths_enabled = #{true_value}" execute "UPDATE application_settings SET throttle_protected_paths_enabled = #{true_value}"
end end
private
def omnibus_protected_paths_present?
Rack::Attack.throttles.key?('protected paths')
rescue e
say "Error while checking if Omnibus protected paths were already enabled: #{e.message}"
say 'Continuing. Protected paths will remain enabled.'
# Return true so we don't take a risk
true
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment