omg-actionpack 8.0.0.alpha7 → 8.0.0.alpha9

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: 641622fc7e5ee6fc52a44fd241aaef220c19edf1750c5481b8dff0225cc86a30
4
+ data.tar.gz: e35f78cb7a1e637259c6dc2ccf2709d04cdbbe507a664d4de906039a02870a4c
5
5
  SHA512:
6
- metadata.gz: 6bb87a22c1c212bd6d96ccce823bb33a5ce6a503be9279fa7ed53cf21e3a35f484c161233ff05f840836cd01a9d57bb76344c699c2f289231398060c2354b5b4
7
- data.tar.gz: 0c07ee452b11e18fb3e7acd6da65e813c5b82d1d1ab6705fdb8b060b3237985b43b7fbb27bb7d2de8d7023e86b37f4974d1818c63e1fd336d2cf8c55340ca3a6
6
+ metadata.gz: ded415b6f7b40c38e1da7e5b969644d72a71b723f3f835012ac021973ad15c117ae7492aa2b69499d1c0b021e3f56ab36907552cfe81c65f2380745bcd33cb4d
7
+ data.tar.gz: 32f017addf1ee8b4bbaf54bf05989545ce83bb388fd005c9f4b2c111212dda7367ca383e710bbabcc120e06cb94994ed2b6550d418f978f1c2a2d1dbcb6e7a48
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ ## Rails 8.0.0.alpha9 (September 25, 2024) ##
2
+
3
+ * No changes.
4
+
5
+
6
+ ## Rails 8.0.0.alpha8 (September 18, 2024) ##
7
+
8
+ * No changes.
9
+
10
+
1
11
  ## Rails 8.0.0.alpha7 (September 18, 2024) ##
2
12
 
3
13
  * 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,20 @@ 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: nil, **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
+ cache_key = ["rate-limit", controller_path, name, instance_exec(&by)].compact.join(":")
63
+ count = store.increment(cache_key, 1, expires_in: within)
55
64
  if count && count > to
56
65
  ActiveSupport::Notifications.instrument("rate_limit.action_controller", request: request) do
57
66
  instance_exec(&with)
@@ -19,7 +19,7 @@ module ActionDispatch
19
19
  #
20
20
  # Requests can opt-out of redirection with `exclude`:
21
21
  #
22
- # config.ssl_options = { redirect: { exclude: -> request { /healthcheck/.match?(request.path) } } }
22
+ # config.ssl_options = { redirect: { exclude: -> request { request.path == "/up" } } }
23
23
  #
24
24
  # Cookies will not be flagged as secure for excluded requests.
25
25
  #
@@ -1053,6 +1053,7 @@ module ActionDispatch
1053
1053
  end
1054
1054
 
1055
1055
  # Allows you to set default parameters for a route, such as this:
1056
+ #
1056
1057
  # defaults id: 'home' do
1057
1058
  # match 'scoped_pages/(:id)', to: 'pages#show'
1058
1059
  # end
@@ -12,7 +12,7 @@ module ActionPack
12
12
  MAJOR = 8
13
13
  MINOR = 0
14
14
  TINY = 0
15
- PRE = "alpha7"
15
+ PRE = "alpha9"
16
16
 
17
17
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
18
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
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.alpha9
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-18 00:00:00.000000000 Z
11
+ date: 2024-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omg-activesupport
@@ -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.alpha9
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.alpha9
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.alpha9
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.alpha9
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.alpha9
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.alpha9
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.alpha9/actionpack/CHANGELOG.md
351
+ documentation_uri: https://api.rubyonrails.org/v8.0.0.alpha9/
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.alpha9/actionpack
354
354
  rubygems_mfa_required: 'true'
355
355
  post_install_message:
356
356
  rdoc_options: []