rack-recaptcha 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +18 -9
- data/lib/rack/recaptcha.rb +2 -3
- data/rack-recaptcha.gemspec +2 -2
- data/test/teststrap.rb +1 -6
- metadata +6 -6
data/README.md
CHANGED
@@ -19,31 +19,34 @@ You have to require 'rack-recaptcha' in your gemfile.
|
|
19
19
|
|
20
20
|
* :public_key -- your ReCaptcha API public key *(required)*
|
21
21
|
* :private_key -- your ReCaptcha API private key *(required)*
|
22
|
-
* :paths -- where user goes to login or access the recaptcha (array of paths or single path)
|
23
|
-
|
24
22
|
|
25
23
|
Now configure your app to use the middleware. This might be different across each web framework.
|
26
24
|
|
27
25
|
#### Sinatra
|
28
26
|
## app.rb
|
29
|
-
use Rack::Recaptcha, :public_key => 'KEY', :private_key => 'SECRET'
|
27
|
+
use Rack::Recaptcha, :public_key => 'KEY', :private_key => 'SECRET'
|
30
28
|
helpers Rack::Recaptcha::Helpers
|
31
29
|
|
32
30
|
#### Padrino
|
33
31
|
|
34
32
|
## app/app.rb
|
35
|
-
use Rack::Recaptcha, :public_key => 'KEY', :private_key => 'SECRET'
|
33
|
+
use Rack::Recaptcha, :public_key => 'KEY', :private_key => 'SECRET'
|
36
34
|
helpers Rack::Recaptcha::Helpers
|
37
35
|
|
38
36
|
|
39
37
|
#### Rails
|
40
38
|
|
41
|
-
##
|
42
|
-
|
43
|
-
|
39
|
+
## application.rb:
|
40
|
+
class Application < Rails::Application
|
41
|
+
# ...
|
42
|
+
config.gem 'rack-recaptcha', :lib => 'rack/recaptcha'
|
43
|
+
config.middleware.use Rack::Recaptcha, :public_key => 'KEY', :private_key => 'SECRET'
|
44
|
+
end
|
44
45
|
|
45
|
-
##
|
46
|
-
|
46
|
+
## application_helper.rb
|
47
|
+
module ApplicationHelper
|
48
|
+
include Rack::Recaptcha::Helpers
|
49
|
+
end
|
47
50
|
|
48
51
|
### Helpers
|
49
52
|
|
@@ -80,6 +83,12 @@ In Padrino, here's how you would use the helpers.
|
|
80
83
|
end
|
81
84
|
end
|
82
85
|
|
86
|
+
In rails, you'll need to use also use the raw method:
|
87
|
+
|
88
|
+
## new.html.haml
|
89
|
+
- form_tag '/login' do
|
90
|
+
= raw recaptcha_tag(:challenge)
|
91
|
+
= submit_tag "Submit"
|
83
92
|
|
84
93
|
### Contributors
|
85
94
|
|
data/lib/rack/recaptcha.rb
CHANGED
@@ -15,7 +15,7 @@ module Rack
|
|
15
15
|
# Initialize the Rack Middleware. Some of the available options are:
|
16
16
|
# :public_key -- your ReCaptcha API public key *(required)*
|
17
17
|
# :private_key -- your ReCaptcha API private key *(required)*
|
18
|
-
#
|
18
|
+
#
|
19
19
|
def initialize(app,options = {})
|
20
20
|
@app = app
|
21
21
|
@paths = options[:paths] && [options[:paths]].flatten.compact
|
@@ -29,8 +29,7 @@ module Rack
|
|
29
29
|
|
30
30
|
def _call(env)
|
31
31
|
request = Request.new(env)
|
32
|
-
if request.params[CHALLENGE_FIELD] and
|
33
|
-
request.params[RESPONSE_FIELD] and (not @paths or @paths.include?(request.path))
|
32
|
+
if request.params[CHALLENGE_FIELD] and request.params[RESPONSE_FIELD]
|
34
33
|
value, msg = verify(
|
35
34
|
request.ip,
|
36
35
|
request.params[CHALLENGE_FIELD],
|
data/rack-recaptcha.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{rack-recaptcha}
|
3
|
-
s.version = "0.
|
3
|
+
s.version = "0.4.0"
|
4
4
|
s.required_rubygems_version = ">=1.3.6"
|
5
5
|
s.authors = ["Arthur Chiu"]
|
6
6
|
s.date = %q{2010-07-18}
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.summary = %q{Rack middleware for Recaptcha}
|
16
16
|
s.test_files = Dir.glob("test/**/*")
|
17
17
|
s.add_runtime_dependency "json", ">= 0"
|
18
|
-
s.add_development_dependency "riot", "~> 0.12.
|
18
|
+
s.add_development_dependency "riot", "~> 0.12.3"
|
19
19
|
s.add_development_dependency "rack-test", "~> 0.5.7"
|
20
20
|
s.add_development_dependency "fakeweb", "~> 1.3.0"
|
21
21
|
s.add_development_dependency "rr", "~> 1.0.2"
|
data/test/teststrap.rb
CHANGED
@@ -35,16 +35,11 @@ class Riot::Situation
|
|
35
35
|
}
|
36
36
|
|
37
37
|
builder = Rack::Builder.new
|
38
|
-
builder.use Rack::Recaptcha, :private_key => PRIVATE_KEY, :public_key => PUBLIC_KEY
|
38
|
+
builder.use Rack::Recaptcha, :private_key => PRIVATE_KEY, :public_key => PUBLIC_KEY
|
39
39
|
builder.run main_app
|
40
40
|
builder.to_app
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
class Riot::Context
|
45
|
-
|
46
|
-
# denies_topic currently on edge. Will remove once its released
|
47
|
-
def denies_topic(what)
|
48
|
-
denies(what) { topic }
|
49
|
-
end
|
50
45
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-recaptcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 4
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Arthur Chiu
|
@@ -40,12 +40,12 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
hash:
|
43
|
+
hash: 41
|
44
44
|
segments:
|
45
45
|
- 0
|
46
46
|
- 12
|
47
|
-
-
|
48
|
-
version: 0.12.
|
47
|
+
- 3
|
48
|
+
version: 0.12.3
|
49
49
|
type: :development
|
50
50
|
version_requirements: *id002
|
51
51
|
- !ruby/object:Gem::Dependency
|