omg-actionpack 8.0.0.alpha7 → 8.0.0.alpha8

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: e3204c7873531fd0e3a533bed5965fd6b7d3b2c2a27b3ae520b22d432d4720b7
4
- data.tar.gz: d70c6182ad609b8ee52f911ac36fcf94ba8448ed1734346bb83f022ae97cf078
3
+ metadata.gz: 25af50ef776cddbe4644faf9005396c435dc06ab1a96f9d36804d3e403d81551
4
+ data.tar.gz: 22e5847f38d2bc79e75ac4a8c9f974a11aae7124843ec3a0c9f54760d0f3ff14
5
5
  SHA512:
6
- metadata.gz: 6bb87a22c1c212bd6d96ccce823bb33a5ce6a503be9279fa7ed53cf21e3a35f484c161233ff05f840836cd01a9d57bb76344c699c2f289231398060c2354b5b4
7
- data.tar.gz: 0c07ee452b11e18fb3e7acd6da65e813c5b82d1d1ab6705fdb8b060b3237985b43b7fbb27bb7d2de8d7023e86b37f4974d1818c63e1fd336d2cf8c55340ca3a6
6
+ metadata.gz: 19a2eab60987fc7ac73e9016a597f6ad455c5ad8c6263467170a599cef43c4e190f3bcb2fecb29b68c316042c551549d5cd243130e262a26c6668747ecc12851
7
+ data.tar.gz: 78c5eefefc12807643fe1d0ba218b3311666fb3761e9131c8b6d282783655c790203f003fa71a019f7c7183d8550e95d778ba2c2bc82383c58d9bb7d917d2417
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## Rails 8.0.0.alpha8 (September 18, 2024) ##
2
+
3
+ * No changes.
4
+
5
+
1
6
  ## Rails 8.0.0.alpha7 (September 18, 2024) ##
2
7
 
3
8
  * No changes.
@@ -29,6 +29,9 @@ module ActionController # :nodoc:
29
29
  # datastore as your general caches, you can pass a custom store in the `store`
30
30
  # parameter.
31
31
  #
32
+ # If you want to use multiple rate limits per controller, you need to give each of
33
+ # them and explicit name via the `name:` option.
34
+ #
32
35
  # Examples:
33
36
  #
34
37
  # class SessionsController < ApplicationController
@@ -44,14 +47,19 @@ module ActionController # :nodoc:
44
47
  # RATE_LIMIT_STORE = ActiveSupport::Cache::RedisCacheStore.new(url: ENV["REDIS_URL"])
45
48
  # rate_limit to: 10, within: 3.minutes, store: RATE_LIMIT_STORE
46
49
  # end
47
- def rate_limit(to:, within:, by: -> { request.remote_ip }, with: -> { head :too_many_requests }, store: cache_store, **options)
48
- before_action -> { rate_limiting(to: to, within: within, by: by, with: with, store: store) }, **options
50
+ #
51
+ # class SessionsController < ApplicationController
52
+ # rate_limit to: 3, within: 2.seconds, name: "short-term"
53
+ # rate_limit to: 10, within: 5.minutes, name: "long-term"
54
+ # end
55
+ def rate_limit(to:, within:, by: -> { request.remote_ip }, with: -> { head :too_many_requests }, store: cache_store, name: controller_path, **options)
56
+ before_action -> { rate_limiting(to: to, within: within, by: by, with: with, store: store, name: name) }, **options
49
57
  end
50
58
  end
51
59
 
52
60
  private
53
- def rate_limiting(to:, within:, by:, with:, store:)
54
- count = store.increment("rate-limit:#{controller_path}:#{instance_exec(&by)}", 1, expires_in: within)
61
+ def rate_limiting(to:, within:, by:, with:, store:, name:)
62
+ count = store.increment("rate-limit:#{name}:#{instance_exec(&by)}", 1, expires_in: within)
55
63
  if count && count > to
56
64
  ActiveSupport::Notifications.instrument("rate_limit.action_controller", request: request) do
57
65
  instance_exec(&with)
@@ -12,7 +12,7 @@ module ActionPack
12
12
  MAJOR = 8
13
13
  MINOR = 0
14
14
  TINY = 0
15
- PRE = "alpha7"
15
+ PRE = "alpha8"
16
16
 
17
17
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
18
18
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omg-actionpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.0.alpha7
4
+ version: 8.0.0.alpha8
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 8.0.0.alpha7
19
+ version: 8.0.0.alpha8
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 8.0.0.alpha7
26
+ version: 8.0.0.alpha8
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -128,28 +128,28 @@ dependencies:
128
128
  requirements:
129
129
  - - '='
130
130
  - !ruby/object:Gem::Version
131
- version: 8.0.0.alpha7
131
+ version: 8.0.0.alpha8
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - '='
137
137
  - !ruby/object:Gem::Version
138
- version: 8.0.0.alpha7
138
+ version: 8.0.0.alpha8
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: omg-activemodel
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
143
  - - '='
144
144
  - !ruby/object:Gem::Version
145
- version: 8.0.0.alpha7
145
+ version: 8.0.0.alpha8
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - '='
151
151
  - !ruby/object:Gem::Version
152
- version: 8.0.0.alpha7
152
+ version: 8.0.0.alpha8
153
153
  description: Web apps on Rails. Simple, battle-tested conventions for building and
154
154
  testing MVC web applications. Works with any Rack-compatible server.
155
155
  email: david@loudthinking.com
@@ -347,10 +347,10 @@ licenses:
347
347
  - MIT
348
348
  metadata:
349
349
  bug_tracker_uri: https://github.com/rails/rails/issues
350
- changelog_uri: https://github.com/rails/rails/blob/v8.0.0.alpha7/actionpack/CHANGELOG.md
351
- documentation_uri: https://api.rubyonrails.org/v8.0.0.alpha7/
350
+ changelog_uri: https://github.com/rails/rails/blob/v8.0.0.alpha8/actionpack/CHANGELOG.md
351
+ documentation_uri: https://api.rubyonrails.org/v8.0.0.alpha8/
352
352
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
353
- source_code_uri: https://github.com/rails/rails/tree/v8.0.0.alpha7/actionpack
353
+ source_code_uri: https://github.com/rails/rails/tree/v8.0.0.alpha8/actionpack
354
354
  rubygems_mfa_required: 'true'
355
355
  post_install_message:
356
356
  rdoc_options: []