rack-attack-recaptcha 0.0.2 → 0.0.3
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/README.md +28 -20
- data/lib/rack/attack/recaptcha.rb +1 -0
- data/lib/rack/attack/recaptcha/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9055f29ff737aa2780619212a90152dcb21f0a16
|
|
4
|
+
data.tar.gz: 8b6907e03be3df56a6a89cbdf933b421103c808f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1003c1bbf023f96ab708b61e678dc9200a2e94c30ddc075d03bfe5cc1086a8e8a9855a40c3e5d01e6e96a14223805b275afac59d4a3244bbe1495c8b01e06aa7
|
|
7
|
+
data.tar.gz: 7061f9f2763e09c072e37f82ed503b6126ad9dcf90b541d07c6405af7674c5ec58679f97ba48541004769c802625c5692cba56b0be306c758f3b2d447dc5b716
|
data/README.md
CHANGED
|
@@ -28,15 +28,19 @@ And then execute:
|
|
|
28
28
|
|
|
29
29
|
Tell your app to use the Rack::Attack middleware. For Rails 3+ apps:
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
```ruby
|
|
32
|
+
# In config/application.rb
|
|
33
|
+
config.middleware.use Rack::Attack::Recaptcha
|
|
34
|
+
```
|
|
33
35
|
|
|
34
36
|
To setup Recaptcha throttles, you should specify the throttle's type to
|
|
35
37
|
be `:recaptcha` as shown here:
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
```ruby
|
|
40
|
+
Rack::Attack.throttle('req/ip', :limit => 5, :period => 1.second, :type => :recaptcha) do |req|
|
|
41
|
+
req.ip
|
|
42
|
+
end
|
|
43
|
+
```
|
|
40
44
|
|
|
41
45
|
Check out [rack-attack's](https://github.com/kickstarter/rack-attack)'s wiki for more details on setting throttles.
|
|
42
46
|
To setup Recaptcha credentials, check out [recaptcha](http://github.com/ambethia/recaptcha)'s wiki.
|
|
@@ -48,28 +52,32 @@ you want the Recaptcha widget to appear.
|
|
|
48
52
|
|
|
49
53
|
Example:
|
|
50
54
|
|
|
51
|
-
|
|
55
|
+
```ruby
|
|
56
|
+
# app/views/foos/foo.html.erb
|
|
52
57
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
<%= form_for @foo do |f| %>
|
|
59
|
+
# ... additional lines truncated for brevity ...
|
|
60
|
+
<%= recaptcha_tags_if_under_attack %>
|
|
61
|
+
# ... additional lines truncated for brevity ...
|
|
62
|
+
<% end %>
|
|
63
|
+
```
|
|
58
64
|
|
|
59
65
|
_(If the request is legit, `recaptcha_tags_if_under_attack` will render nothing.)_
|
|
60
66
|
|
|
61
67
|
Now add `verify_recaptcha_if_under_attack` logic to each form action that you've
|
|
62
68
|
protected:
|
|
63
69
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
70
|
+
```ruby
|
|
71
|
+
# app/controllers/foos_controller.rb
|
|
72
|
+
|
|
73
|
+
def create
|
|
74
|
+
if verify_recaptcha_if_under_attack && @foo.save
|
|
75
|
+
# ...
|
|
76
|
+
else
|
|
77
|
+
# ...
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
```
|
|
73
81
|
|
|
74
82
|
_(If the request is legit,
|
|
75
83
|
`verify_recaptcha_if_under_attack` won't actually check the captcha and
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rack-attack-recaptcha
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Omer Lachish-Rauchwerger
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-09-
|
|
11
|
+
date: 2014-09-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|