Commit graph

251 commits

Author SHA1 Message Date
Aaron Suggs
ab0d17c3ef rake: add bundler/gem_tasks 2015-05-22 15:10:34 -04:00
Aaron Suggs
1981b38063 [travis] Test activesupport 4.2 2015-05-22 14:29:08 -04:00
Aaron Suggs
3aee014a8c [travis] Test ruby 2.2.2 2015-05-22 13:49:32 -04:00
Aaron Suggs
64fe10f64e Clarifying comments for #delete spec method 2015-05-22 13:48:32 -04:00
Aaron Suggs
b29a7a89de Update CHANGELOG for release 2015-05-22 13:48:15 -04:00
Aaron Suggs
f0941a225b Merge pull request #128 from stanhu/support-reset-throttles
Provide the ability to reset Fail2Ban count and ban flag
2015-05-22 13:43:28 -04:00
Stan Hu
91947b83a4 Support the ability to reset Fail2Ban count and ban flag
Closes #113
2015-05-22 09:47:32 -04:00
Aaron Suggs
919976cb64 Merge pull request #129 from HayleyCAnderson/master
Fix typos in README
2015-05-14 13:43:48 -04:00
Hayley Anderson
e1e315181a Fix typos
* Change "you Gemfile" to "your Gemfile"
* Change "config/initalizers" to "config/initializers"
2015-05-13 11:30:25 -04:00
Aaron Suggs
e25ab0a313 Merge pull request #124 from jasl/patch-1
Update README.md
2015-04-18 21:58:33 -04:00
Jun Jiang
0b3c638409 Update README.md 2015-04-19 06:14:03 +08:00
Aaron Suggs
3e0fcc24a4 Update changelog 2015-04-16 14:14:55 -04:00
Aaron Suggs
0ec73d956b Merge pull request #119 from stanhu/add-delete-interface
Support delete method for Redis
2015-04-16 14:11:58 -04:00
Aaron Suggs
1dd29f66b8 Update changelog for #118; bump to v4.3.0 2015-04-16 14:06:46 -04:00
Aaron Suggs
7dd9a9dd8a Merge pull request #118 from stanhu/fix-redis-write-options
Pass `raw: true` to prevent Ruby de/serialization. This is to make it po...
2015-04-16 13:54:17 -04:00
Stan Hu
ff15447f3a Support delete method for Redis 2015-03-15 12:13:44 -07:00
Stan Hu
dc1b6bf687 Pass raw: true to prevent Ruby de/serialization. This is to make it possible
to implement something like:

```store.write(key, 0, :expires_in => expires_in)```

See #113
2015-03-15 07:18:18 -07:00
Aaron Suggs
efdef7f45c Merge branch 'lucaspinto-master'
Fixes #117
2015-03-06 15:48:42 -05:00
Aaron Suggs
77d0493bc4 README: link to Rack::Request documentation 2015-03-06 15:47:32 -05:00
Lucas "medk" Pinto
5fbe7de686 Change Rack::Request URL in the README 2015-03-06 13:37:33 +01:00
Aaron Suggs
b0bf74f9d9 Fix test assertion 2015-01-27 16:18:55 -05:00
Aaron Suggs
0c0e6a6e85 Merge pull request #104 from dlackty/patch-1
Update changelog for 4.2.0
2014-11-21 10:03:59 -05:00
Richard Lee
bc4899238d Update changelog for 4.2.0 2014-11-21 16:54:27 +08:00
Aaron Suggs
f9b7721e59 bump version 4.2.0 2014-10-26 15:33:09 -04:00
Aaron Suggs
25739e24db Update CHANGELOG.md 2014-10-02 14:28:02 -04:00
Aaron Suggs
e7efe1cf5f Merge pull request #91 from gsamokovarov/call-responses
Invoke Rack:::{blacklisted,throttled}_response with #call
2014-10-02 14:25:42 -04:00
Aaron Suggs
a1cedbbc7e Merge pull request #93 from gsamokovarov/dont-rescue-nil
Avoid rescue nil in the default throttled response
2014-09-26 15:07:35 -04:00
Aaron Suggs
7781e3a6ab Merge pull request #88 from gsamokovarov/throttle-period-proc
Allow throttle period option to be a proc
2014-09-26 15:04:07 -04:00
Genadi Samokovarov
a161176142 Invoke {blacklisted,throttled}_response with #call
I have a response which is a class. While I can still have my class
implement `#[]`, it does look a bit off. On the other side, having
objects, responding to #call, that are not procs is pretty common.

So I propose to invoke the responses with `#call` to let users override
it with response objects, that respond to `#call` instead of `#[]`.
2014-09-25 23:21:02 +02:00
Genadi Samokovarov
f737dbb78c Avoid rescue nil in the default throttled response
It has a couple of cons:

1. If we slip a typo in the whole line, we won't easily catch it.  Can
   you guys spot the problem problem in the following line? Chasing such
   issues is quite tricky.

```ruby
retry_after = evn['rack.attack.match_data'][:period] rescue nil
```

2. Throwing and catching an exception is quite slower than a new hash
   allocation, so there is a speed benefit too.

We are guaranteed from Rack that env is a `Hash`, so we can even use
`Hash#fetch`.

```ruby
retry_after = env.fetch('rack.attack.match_data', {})[:period]
```

This reads better, but always allocates the default value hash, when the
other version allocates it only when needed. If you prefer `Hash#fetch`,
I'm fine with that, as long as we avoid `rescue nil`.
2014-09-25 18:35:53 +02:00
Genadi Samokovarov
d9a5587676 Allow throttle period option to be a proc
I need to filter requests on a period I need to get dynamically out of
information I have in the requests. Currently, I can work out the limit,
as it can be a `Proc`, however I can't do that with the period.

This PR adds support for that. Tried to do it in a way that doesn't
brake backwards compatibility, as periods are coerced to numbers during
`Rack::Throttle` initialization.
2014-09-19 19:32:39 +02:00
Aaron Suggs
60d4834969 update changelog for release 2014-09-11 16:23:35 -04:00
Aaron Suggs
1db5a00431 version 4.1.1 2014-09-08 21:34:28 -04:00
Aaron Suggs
8d3e824068 Merge pull request #85 from kickstarter/69-spec-failures
Add 1 second buffer to expiry to correct throttles
2014-09-08 21:28:31 -04:00
Aaron Suggs
074e8e5aa4 Add 1 second buffer to expiry to correct throttles
Fixes #69.

There was a race condition when `Time.now.to_i` changes between when
`epoch_time` is computed in line 18, and the cache request is made (and
the `key` is expired).

I.e., a throttle check starts at t0, but doesn’t reach the cache until
t1, the cache will have expired the throttle count. The request will
likely be allowed, even if the request exceeded the limit.

This has the effect of keeping keys in cache about 1 second longer than
strictly necessary. But the extra cache space seems like a good
trade-off for correct throttling.
2014-09-02 14:30:57 -04:00
Aaron Suggs
ba52e2ce15 Merge pull request #82 from brchristian/patch-1
Fix typo in README.md
2014-08-15 12:21:16 -04:00
brchristian
4a724d8c8b Fix typo in README.md 2014-08-15 09:03:38 -07:00
Aaron Suggs
7820986d9c Merge pull request #74 from zmillman/readme-request
Improve documentation of Rack::Attack::Request
2014-08-01 14:43:53 -04:00
Aaron Suggs
502e5ae108 Merge pull request #76 from greysteil/clean-up-travis
Clean up travis.yml
2014-06-20 10:09:13 -04:00
Grey Baker
78663d4a93 Clean up travis.yml 2014-06-20 14:36:48 +01:00
Zach Millman
882221212a Fix formatting of note on Rack::Attack::Request 2014-06-17 11:38:50 -07:00
Zach Millman
5c78f84be2 Improve documentation of Rack::Attack::Request
https://github.com/kickstarter/rack-attack/issues/73
2014-06-17 11:37:25 -07:00
Aaron Suggs
1a3cddb468 Prep for v4.1.0 2014-05-22 13:59:26 -04:00
Aaron Suggs
105c3ba575 Merge pull request #67 from chiliburger/track_only
Limit and period options for track
2014-05-22 13:55:54 -04:00
Paul Coates
e8d98a7ad3 Changed track checker to track filter. Made track filter tests more clear. 2014-05-22 10:11:23 -07:00
Aaron Suggs
6f7bd66dfa Default responses: add Content-Type header
Fixes #68
2014-05-21 18:35:28 -04:00
Paul Coates
1857f8dd57 Added track with limit/period options example to the README.md for clarity. 2014-05-19 12:30:18 -07:00
Paul Coates
c51676d295 Updated README.md to reflect optional limit and period parmas for tracks. 2014-05-19 11:14:50 -07:00
Paul Coates
1ebe1c3517 Added limit and period options to track. Delegates [] to Throttle if they are present otherwise Check. 2014-05-19 11:11:01 -07:00
Aaron Suggs
1fbcb479f1 Merge pull request #66 from rickygu/patch-1
Update README.md
2014-05-18 20:48:35 -04:00