rack-attack 6.6.0 → 6.6.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
  SHA256:
3
- metadata.gz: c87eb44c705e3cfd5e5724266185a989cd60c44333ad211f21789a6778f18ac1
4
- data.tar.gz: 54761820c0b6dd8ef062d6cce59f1807d98a05e9f00ffa2eadf7e4258a557ed3
3
+ metadata.gz: '0399127f00624959bafee349ab2e6010acda84373c3df24ff18c3ff701a6c274'
4
+ data.tar.gz: 88bbb4465f8b7ecd0f82d9ad7217a66da96bb829c6982b0151ea2c19b5bba3c5
5
5
  SHA512:
6
- metadata.gz: 4a9382dcf4a307716eb77a4d232a081e0354c8f81c78d71076518db9939daed4319fbf605714514438c538f8e0c75c99b90a6f261730d67831af66a0b7208f57
7
- data.tar.gz: dc207b3c238721aee545025c12440ae83ab6d924ceaeecaaaaa25b84a546f579d3518476ca2f55d5839fc24170d1a0ae7b95bd424ed57b84c23f74afa271922b
6
+ metadata.gz: 5a4d3d278b7c814c909ae0e01128f076f2ffcda003a56f688d803ccdfc5f72eeaa6c60412dc8e06769026f407860ac1259668fc61c0e87f1ef7a03434e17d982
7
+ data.tar.gz: 492e4659338b489d9fcdc3bd315148ec2e1802c6197ce4dc5d7eaf598c918866468387d1a2346bfc30c454605aeaa59aa7d9a4e50bdc08910b24a72c681053dc
data/README.md CHANGED
@@ -347,8 +347,8 @@ Rack::Attack.throttled_response_retry_after_header = true
347
347
  Here's an example response that includes conventional `RateLimit-*` headers:
348
348
 
349
349
  ```ruby
350
- Rack::Attack.throttled_response = lambda do |env|
351
- match_data = env['rack.attack.match_data']
350
+ Rack::Attack.throttled_responder = lambda do |request|
351
+ match_data = request.env['rack.attack.match_data']
352
352
  now = match_data[:epoch_time]
353
353
 
354
354
  headers = {
@@ -5,7 +5,7 @@ require "ipaddr"
5
5
  module Rack
6
6
  class Attack
7
7
  class Configuration
8
- DEFAULT_BLOCKLISTED_RESPONDER = lambda { |_req| [403, { 'Content-Type' => 'text/plain' }, ["Forbidden\n"]] }
8
+ DEFAULT_BLOCKLISTED_RESPONDER = lambda { |_req| [403, { 'content-type' => 'text/plain' }, ["Forbidden\n"]] }
9
9
 
10
10
  DEFAULT_THROTTLED_RESPONDER = lambda do |req|
11
11
  if Rack::Attack.configuration.throttled_response_retry_after_header
@@ -13,9 +13,9 @@ module Rack
13
13
  now = match_data[:epoch_time]
14
14
  retry_after = match_data[:period] - (now % match_data[:period])
15
15
 
16
- [429, { 'Content-Type' => 'text/plain', 'Retry-After' => retry_after.to_s }, ["Retry later\n"]]
16
+ [429, { 'content-type' => 'text/plain', 'retry-after' => retry_after.to_s }, ["Retry later\n"]]
17
17
  else
18
- [429, { 'Content-Type' => 'text/plain' }, ["Retry later\n"]]
18
+ [429, { 'content-type' => 'text/plain' }, ["Retry later\n"]]
19
19
  end
20
20
  end
21
21
 
@@ -32,9 +32,9 @@ module Rack
32
32
 
33
33
  def increment(key, amount, options = {})
34
34
  rescuing do
35
- pipelined do
36
- incrby(key, amount)
37
- expire(key, options[:expires_in]) if options[:expires_in]
35
+ pipelined do |redis|
36
+ redis.incrby(key, amount)
37
+ redis.expire(key, options[:expires_in]) if options[:expires_in]
38
38
  end.first
39
39
  end
40
40
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rack
4
4
  class Attack
5
- VERSION = '6.6.0'
5
+ VERSION = '6.6.1'
6
6
  end
7
7
  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: 6.6.0
4
+ version: 6.6.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: 2022-01-29 00:00:00.000000000 Z
11
+ date: 2022-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -273,7 +273,7 @@ licenses:
273
273
  - MIT
274
274
  metadata:
275
275
  bug_tracker_uri: https://github.com/rack/rack-attack/issues
276
- changelog_uri: https://github.com/rack/rack-attack/blob/master/CHANGELOG.md
276
+ changelog_uri: https://github.com/rack/rack-attack/blob/main/CHANGELOG.md
277
277
  source_code_uri: https://github.com/rack/rack-attack
278
278
  post_install_message:
279
279
  rdoc_options:
@@ -291,7 +291,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
291
291
  - !ruby/object:Gem::Version
292
292
  version: '0'
293
293
  requirements: []
294
- rubygems_version: 3.3.6
294
+ rubygems_version: 3.3.11
295
295
  signing_key:
296
296
  specification_version: 4
297
297
  summary: Block & throttle abusive requests