mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-03-25 09:25:49 +00:00
Don't autoplug middleware for untested rails versions
This commit is contained in:
parent
f65431f788
commit
1167c65ba6
3 changed files with 4 additions and 4 deletions
|
|
@ -71,7 +71,7 @@ Or install it yourself as:
|
|||
|
||||
Then tell your ruby web application to use rack-attack as a middleware.
|
||||
|
||||
a) For __rails__ applications with versions >= 5 it is used by default. For older rails versions you should enable it explicitly:
|
||||
a) For __rails__ applications with versions >= 5.1 it is used by default. For older rails versions you should enable it explicitly:
|
||||
```ruby
|
||||
# In config/application.rb
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ module Rack
|
|||
class Attack
|
||||
class Railtie < ::Rails::Railtie
|
||||
initializer 'rack.attack.middleware', after: :load_config_initializers, before: :build_middleware_stack do |app|
|
||||
if Gem::Version.new(::Rails::VERSION::STRING) >= Gem::Version.new("5")
|
||||
if Gem::Version.new(::Rails::VERSION::STRING) >= Gem::Version.new("5.1")
|
||||
middlewares = app.config.middleware
|
||||
operations = middlewares.send(:operations) + middlewares.send(:delete_operations)
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ if defined?(Rails)
|
|||
end
|
||||
end
|
||||
|
||||
if Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new("5")
|
||||
if Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new("5.1")
|
||||
it "is used by default" do
|
||||
@app.initialize!
|
||||
assert_equal 1, @app.middleware.count(Rack::Attack)
|
||||
|
|
@ -31,7 +31,7 @@ if defined?(Rails)
|
|||
end
|
||||
end
|
||||
|
||||
if Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new("5")
|
||||
if Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new("5.1")
|
||||
it "is not used by default" do
|
||||
@app.initialize!
|
||||
assert_equal 0, @app.middleware.count(Rack::Attack)
|
||||
|
|
|
|||
Loading…
Reference in a new issue