better_rate_limit 0.1.8 → 0.1.9

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: 9eedeebfe87d1f95a4541b994bcabec39ac02250827174c12da04b612209e4f6
4
- data.tar.gz: 0aee3a1cf32a3e59c8b1307dd6364f6610272366267d4c59644741df3d9006b6
3
+ metadata.gz: 7501160c6bba347fbc8eb40116c5a46c9d500b01d77116ed49e98c8985fb79da
4
+ data.tar.gz: 5ab03fac755181baffa23f4f876bcd331e71295ce56902d11b5d476ac1797ce6
5
5
  SHA512:
6
- metadata.gz: 162d31096ed6a08dc8ca38b18becb34512f25abd99297bd9b03ac7dd0208499dea1fd8ba2871584a9929ba45555734e8a8611c2b3d64df663b3a60128f007ae3
7
- data.tar.gz: b28194386480e1ec62fca06ea62ba8de6ec41eedae07d97710e9afb1bf5af09923fe5f1465a93f3cd85c167f5c18300f74b8242e35eeffed95af66a165ec7c8a
6
+ metadata.gz: 35dabbd3e4cf261c6edc4e87e4ed55793ce492f7992b4dc4fa7ce32d41478fd8c2da7557f4ce19f394dd2e24005a979c211ae5adb23a1d20eadf177f38033778
7
+ data.tar.gz: 92f051eb2ecbe4ab682757ca066ecc2c53680a8f7cb8a938a9772f0dc30c2fe92cdee7d27c1d8deb81c1862ebd43bbc63c1a68c19d23f3228bfce285d4b7ddc7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- better_rate_limit (0.1.6)
4
+ better_rate_limit (0.1.9)
5
5
  actionpack (>= 5.0)
6
6
  redis (>= 3.3)
7
7
 
@@ -29,6 +29,7 @@ GEM
29
29
  builder (3.2.4)
30
30
  coderay (1.1.3)
31
31
  concurrent-ruby (1.1.9)
32
+ connection_pool (2.2.5)
32
33
  crass (1.0.6)
33
34
  erubi (1.10.0)
34
35
  i18n (1.9.1)
@@ -59,7 +60,10 @@ GEM
59
60
  rails-html-sanitizer (1.4.2)
60
61
  loofah (~> 2.3)
61
62
  rake (12.3.3)
62
- redis (4.3.1)
63
+ redis (5.0.3)
64
+ redis-client (>= 0.7.4)
65
+ redis-client (0.8.0)
66
+ connection_pool
63
67
  thread_safe (0.3.6)
64
68
  timecop (0.9.1)
65
69
  tzinfo (1.2.9)
@@ -9,15 +9,15 @@ module ActionController
9
9
  module ClassMethods
10
10
  def rate_limit(max, options)
11
11
  rate_limits << Limit.build(max, controller_path, {
12
- if: options[:if],
13
- unless: options[:unless],
14
- every: options[:every],
15
- name: options[:name] || controller_path,
16
- scope: options[:scope] || -> { real_ip },
17
- only: options[:only] || [],
18
- except: options[:except] || [],
19
- clear_if: options[:clear_if]
20
- })
12
+ if: options[:if],
13
+ unless: options[:unless],
14
+ every: options[:every],
15
+ name: options[:name] || controller_path,
16
+ scope: options[:scope] || -> { real_ip },
17
+ only: options[:only] || [],
18
+ except: options[:except] || [],
19
+ clear_if: options[:clear_if]
20
+ })
21
21
 
22
22
  before_action :perform_rate_limiting
23
23
  after_action :clear_keys
@@ -61,11 +61,12 @@ module ActionController
61
61
  private
62
62
 
63
63
  def json?
64
- request.xhr? || request.format === :json
64
+ request.xhr? || request.format == :json
65
65
  end
66
66
 
67
67
  def real_ip
68
- request.headers['X-Forwarded-For'].try(:split, ',').try(:[], -2..-2).try(:first).try(:strip)
68
+ request.headers['X-Forwarded-For'].try(:split, ',').try(:last,
69
+ ::BetterRateLimit.configuration.proxies_to_trust).try(:first).try(:strip)
69
70
  end
70
71
 
71
72
  def under_rate_limit?(limit)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module BetterRateLimit
4
4
  class Configuration
5
- attr_accessor :ignore, :redis_client
5
+ attr_accessor :ignore, :redis_client, :proxies_to_trust
6
6
 
7
7
  def initialize
8
8
  @ignore = false
@@ -1,3 +1,3 @@
1
1
  module BetterRateLimit
2
- VERSION = '0.1.8'
2
+ VERSION = '0.1.9'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: better_rate_limit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pablo Fonseca
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-07-15 00:00:00.000000000 Z
12
+ date: 2022-09-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  requirements: []
87
- rubygems_version: 3.2.22
87
+ rubygems_version: 3.1.4
88
88
  signing_key:
89
89
  specification_version: 4
90
90
  summary: Rate limit requests