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 +4 -4
- data/CHANGELOG.md +10 -0
- data/lib/action_controller/metal/rate_limiting.rb +13 -4
- data/lib/action_dispatch/middleware/ssl.rb +1 -1
- data/lib/action_dispatch/routing/mapper.rb +1 -0
- data/lib/action_pack/gem_version.rb +1 -1
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 641622fc7e5ee6fc52a44fd241aaef220c19edf1750c5481b8dff0225cc86a30
|
4
|
+
data.tar.gz: e35f78cb7a1e637259c6dc2ccf2709d04cdbbe507a664d4de906039a02870a4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ded415b6f7b40c38e1da7e5b969644d72a71b723f3f835012ac021973ad15c117ae7492aa2b69499d1c0b021e3f56ab36907552cfe81c65f2380745bcd33cb4d
|
7
|
+
data.tar.gz: 32f017addf1ee8b4bbaf54bf05989545ce83bb388fd005c9f4b2c111212dda7367ca383e710bbabcc120e06cb94994ed2b6550d418f978f1c2a2d1dbcb6e7a48
|
data/CHANGELOG.md
CHANGED
@@ -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
|
-
|
48
|
-
|
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
|
-
|
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 {
|
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
|
#
|
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.
|
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-
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
351
|
-
documentation_uri: https://api.rubyonrails.org/v8.0.0.
|
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.
|
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: []
|