rack-attack 4.4.0 → 4.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d06cf65c8cfce9d8611003c5da19f1384273d6d
4
- data.tar.gz: 4e8e0064ab9087fc7503e9e1cb850f6dd10c8838
3
+ metadata.gz: b35131dd58c3ab63a32c6ebeba00cd203c207973
4
+ data.tar.gz: 86113382083a32cec8f0c3a5ed67d45b8a797bba
5
5
  SHA512:
6
- metadata.gz: d66f18bf9e4f6058c2f40339392e38a62f71afd6852eb0f3f30075fe1eb233b5a355b61bcac39dcf109644987c1ae41fb4831d6c0ed206827258f59a06c4883e
7
- data.tar.gz: b5f72dc5abf4c6b27d89b38dfea3ba85cdbed807bf9aced9388c69707f5e8115aa06a32204bd6fc7c49263ea73dff8fbf2914fcb3868b8965b36e0b63729d10c
6
+ metadata.gz: f9b12687222d55512bc1958b56e50b04f2bd87099a3806539df170d321db1e32b992bcff13f18b95875259448a0193f6caf5f5ba63caca0a6a018847a43dfbd3
7
+ data.tar.gz: 227b3c795cf86843e607ec36cb0c5a5ef3bdfe31ffdc7f30788bf935f716129d51574c326f2b29a542955e028b45a28ff282b13d4277e2233cb93842c1cb2d63
@@ -3,26 +3,30 @@ module Rack
3
3
  module StoreProxy
4
4
  PROXIES = [DalliProxy, MemCacheProxy, RedisStoreProxy]
5
5
 
6
+ ACTIVE_SUPPORT_WRAPPER_CLASSES = Set.new(['ActiveSupport::Cache::MemCacheStore', 'ActiveSupport::Cache::RedisStore']).freeze
7
+ ACTIVE_SUPPORT_CLIENTS = Set.new(['Redis::Store', 'Dalli::Client', 'MemCache']).freeze
8
+
6
9
  def self.build(store)
7
- # RedisStore#increment needs different behavior, so detect that
8
- # (method has an arity of 2; must call #expire separately
9
- if (defined?(::ActiveSupport::Cache::RedisStore) && store.is_a?(::ActiveSupport::Cache::RedisStore)) ||
10
- (defined?(::ActiveSupport::Cache::MemCacheStore) && store.is_a?(::ActiveSupport::Cache::MemCacheStore))
10
+ client = unwrap_active_support_stores(store)
11
+ klass = PROXIES.find { |proxy| proxy.handle?(client) }
12
+ klass ? klass.new(client) : client
13
+ end
14
+
11
15
 
12
- # ActiveSupport::Cache::RedisStore doesn't expose any way to set an expiry,
13
- # so use the raw Redis::Store instead.
14
- # We also want to use the underlying Dalli client instead of ::ActiveSupport::Cache::MemCacheStore,
15
- # and the MemCache client if using Rails 3.x
16
- client = store.instance_variable_get(:@data)
17
- if (defined?(::Redis::Store) && client.is_a?(Redis::Store)) ||
18
- (defined?(Dalli::Client) && client.is_a?(Dalli::Client)) || (defined?(MemCache) && client.is_a?(MemCache))
19
- store = store.instance_variable_get(:@data)
20
- end
16
+ private
17
+ def self.unwrap_active_support_stores(store)
18
+ # ActiveSupport::Cache::RedisStore doesn't expose any way to set an expiry,
19
+ # so use the raw Redis::Store instead.
20
+ # We also want to use the underlying Dalli client instead of ::ActiveSupport::Cache::MemCacheStore,
21
+ # and the MemCache client if using Rails 3.x
22
+
23
+ client = store.instance_variable_get(:@data)
24
+ if ACTIVE_SUPPORT_WRAPPER_CLASSES.include?(store.class.to_s) && ACTIVE_SUPPORT_CLIENTS.include?(client.class.to_s)
25
+ client
26
+ else
27
+ store
21
28
  end
22
- klass = PROXIES.find { |proxy| proxy.handle?(store) }
23
- klass ? klass.new(store) : store
24
29
  end
25
-
26
30
  end
27
31
  end
28
32
  end
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Attack
3
- VERSION = '4.4.0'
3
+ VERSION = '4.4.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-attack
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.0
4
+ version: 4.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Suggs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-10 00:00:00.000000000 Z
11
+ date: 2016-02-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack