nexaas-throttle 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +6 -0
- data/README.md +3 -1
- data/lib/nexaas/throttle/configuration.rb +2 -1
- data/lib/nexaas/throttle/guardian.rb +1 -6
- data/lib/nexaas/throttle/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d04c7fa7e0cf23c2a2d1381c1eb971aea3d4cc89
|
4
|
+
data.tar.gz: fa011ca4b2fec123adc1f3efb834222634196c1f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 474d0584b741c34e6a76a108d1d7a9f2b782d38e726e2a46d9fe599d6cf242c8cfff85dbe0d575ee11724f3daa0878f71568f354495bd6ccd3a38a33c9b83866
|
7
|
+
data.tar.gz: 8751747095078371f503f70c084146d575466b5bad8326c262857e18655ba19258b361d0deb27c21a4680abe0f3af944452c7a2060896b7f1412d93a9f4fa7c8
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
## v2.0
|
2
|
+
- The gem no longer checks if the request is made from an API client. See [#6](https://github.com/myfreecomm/nexaas-throttle/pull/6) for discussion.
|
3
|
+
## v1.0
|
4
|
+
- Allow the configuration of user-agents to ignore when throttling. [#5](https://github.com/myfreecomm/nexaas-throttle/pull/5)
|
5
|
+
### v0.1.0
|
6
|
+
- Initial commit
|
data/README.md
CHANGED
@@ -94,7 +94,7 @@ end
|
|
94
94
|
</tr>
|
95
95
|
<tr>
|
96
96
|
<td><code>ignored_user_agents</code></td>
|
97
|
-
<td>
|
97
|
+
<td>An array of User Agents that should be ignored by the throttler. Values are regexes that will be matched against the request User-Agent</td>
|
98
98
|
<td><code>nil</code></td>
|
99
99
|
</tr>
|
100
100
|
</table>
|
@@ -104,6 +104,8 @@ end
|
|
104
104
|
`Nexaas::Throttle` doesn't know how to identify a consumer. Some applications might rely on request IP, others on an API TOKEN. You must provide a way of getting an unique token
|
105
105
|
that identify a request consumer.
|
106
106
|
|
107
|
+
If there is no token, the request will go through and won't be accounted for.
|
108
|
+
|
107
109
|
`Nexaas::Throttle` do this by providing a configuration `request_identifier`, a class where your application would keep the logic that identifies a consumer. This class must have the following
|
108
110
|
interface:
|
109
111
|
|
@@ -37,7 +37,8 @@ module Nexaas
|
|
37
37
|
# @return [Hash]
|
38
38
|
attr_reader :redis_options
|
39
39
|
|
40
|
-
#
|
40
|
+
# An array of User Agents that should be ignored by the throttler.
|
41
|
+
# Values are regexes that will be matched against the request User-Agent.
|
41
42
|
# Example: [/[Gg]oogle/, /Amazon/]
|
42
43
|
# @return [Array]
|
43
44
|
attr_accessor :ignored_user_agents
|
@@ -22,7 +22,7 @@ module Nexaas
|
|
22
22
|
attr_reader :request, :token, :ignored_user_agents
|
23
23
|
|
24
24
|
def validate
|
25
|
-
return if ignore_user_agents? || assets? ||
|
25
|
+
return if ignore_user_agents? || assets? || token.blank?
|
26
26
|
request.env["nexaas.token"] = token
|
27
27
|
yield if block_given?
|
28
28
|
end
|
@@ -32,11 +32,6 @@ module Nexaas
|
|
32
32
|
path.match(/\/assets/).present? || path.match(extensions_regexp).present?
|
33
33
|
end
|
34
34
|
|
35
|
-
def api?
|
36
|
-
content_type = (request.media_type || request.env["Content-Type"]).to_s
|
37
|
-
%w(application/json application/xml).include?(content_type)
|
38
|
-
end
|
39
|
-
|
40
35
|
def extensions_regexp
|
41
36
|
@assets_extensions ||= begin
|
42
37
|
extensions = %w(css js png jpg gif)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexaas-throttle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wanderson Policarpo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- ".rspec"
|
149
149
|
- ".rubocop.yml"
|
150
150
|
- ".travis.yml"
|
151
|
+
- CHANGELOG.md
|
151
152
|
- Gemfile
|
152
153
|
- LICENSE
|
153
154
|
- README.md
|
@@ -182,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
183
|
version: '0'
|
183
184
|
requirements: []
|
184
185
|
rubyforge_project:
|
185
|
-
rubygems_version: 2.6.
|
186
|
+
rubygems_version: 2.6.13
|
186
187
|
signing_key:
|
187
188
|
specification_version: 4
|
188
189
|
summary: A tiny engine to allow throttling and blacklisting requests.
|