recaptcha 3.4.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +11 -11
- data/lib/recaptcha/client_helper.rb +3 -3
- data/lib/recaptcha/configuration.rb +10 -10
- data/lib/recaptcha/verify.rb +2 -2
- data/lib/recaptcha/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d7c9ac18ec9de3fed55d8c19fbf4f673a8c1ff8
|
4
|
+
data.tar.gz: e303da2bfe6fa08bdd1a41b91629bbba37ea9bf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9432fbc21f27f050db6ec0463af0b5ef07fb1ea35a0ed32e78ef53748b9aad43b51563603e63d1a86311082da4d1d7cbc72e07240992dc85693327b292036dde
|
7
|
+
data.tar.gz: 19a54357999754e6eaec65b4bfbe1ad95dc21122fb90aaa6a71f3cf834a94bbb7442734857b0f8dfcb68bcc09a05dfe5065fc515617e8d28296141e91f51ef5c
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -25,8 +25,8 @@ Set in production and locally use [dotenv](https://github.com/bkeepers/dotenv),
|
|
25
25
|
Otherwise see [Alternative API key setup](#alternative-api-key-setup).
|
26
26
|
|
27
27
|
```
|
28
|
-
export
|
29
|
-
export
|
28
|
+
export RECAPTCHA_SITE_KEY = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy'
|
29
|
+
export RECAPTCHA_SECRET_KEY = '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx'
|
30
30
|
```
|
31
31
|
|
32
32
|
Add `recaptcha_tags` to the forms you want to protect.
|
@@ -69,7 +69,7 @@ Some of the options available:
|
|
69
69
|
| :noscript | Include <noscript> content (default `true`)|
|
70
70
|
| :display | Takes a hash containing the `theme` and `tabindex` options per the API. (default `nil`), options: 'red', 'white', 'blackglass', 'clean', 'custom'|
|
71
71
|
| :ajax | Render the dynamic AJAX captcha per the API. (default `false`)|
|
72
|
-
| :
|
72
|
+
| :site_key | Override site API key |
|
73
73
|
| :error | Override the error code returned from the reCAPTCHA API (default `nil`)|
|
74
74
|
| :size | Specify a size (default `nil`)|
|
75
75
|
| :hl | Optional. Forces the widget to render in a specific language. Auto-detects the user's language if unspecified. (See [language codes](https://developers.google.com/recaptcha/docs/language)) |
|
@@ -93,7 +93,7 @@ Some of the options available:
|
|
93
93
|
| :model | Model to set errors.
|
94
94
|
| :attribute | Model attribute to receive errors. (default :base)
|
95
95
|
| :message | Custom error message.
|
96
|
-
| :
|
96
|
+
| :secret_key | Override secret API key.
|
97
97
|
| :timeout | The number of seconds to wait for reCAPTCHA servers before give up. (default `3`)
|
98
98
|
| :response | Custom response parameter. (default: params['g-recaptcha-response'])
|
99
99
|
| :hostname | Expected hostname or a callable that validates the hostname, see [domain validation](https://developers.google.com/recaptcha/docs/domain_validation) and [hostname](https://developers.google.com/recaptcha/docs/verify#api-response) docs. (default: `nil`, but can be changed by setting `config.hostname`)
|
@@ -113,7 +113,7 @@ Also you can translate API response errors to human friendly by adding translati
|
|
113
113
|
en:
|
114
114
|
recaptcha:
|
115
115
|
errors:
|
116
|
-
|
116
|
+
verification_failed: 'Fail'
|
117
117
|
```
|
118
118
|
|
119
119
|
## Testing
|
@@ -131,8 +131,8 @@ Recaptcha.configuration.skip_verify_env.delete("test")
|
|
131
131
|
```Ruby
|
132
132
|
# config/initializers/recaptcha.rb
|
133
133
|
Recaptcha.configure do |config|
|
134
|
-
config.
|
135
|
-
config.
|
134
|
+
config.site_key = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy'
|
135
|
+
config.secret_key = '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx'
|
136
136
|
# Uncomment the following line if you are using a proxy server:
|
137
137
|
# config.proxy = 'http://myproxy.com.au:8080'
|
138
138
|
end
|
@@ -143,8 +143,8 @@ end
|
|
143
143
|
For temporary overwrites (not thread safe).
|
144
144
|
|
145
145
|
```Ruby
|
146
|
-
Recaptcha.with_configuration(
|
147
|
-
# Do stuff with the overwritten
|
146
|
+
Recaptcha.with_configuration(site_key: '12345') do
|
147
|
+
# Do stuff with the overwritten site_key.
|
148
148
|
end
|
149
149
|
```
|
150
150
|
|
@@ -153,11 +153,11 @@ end
|
|
153
153
|
Pass in keys as options at runtime, for code base with multiple reCAPTCHA setups:
|
154
154
|
|
155
155
|
```Ruby
|
156
|
-
recaptcha_tags
|
156
|
+
recaptcha_tags site_key: '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy'
|
157
157
|
|
158
158
|
and
|
159
159
|
|
160
|
-
verify_recaptcha
|
160
|
+
verify_recaptcha secret_key: '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx'
|
161
161
|
```
|
162
162
|
|
163
163
|
## Misc
|
@@ -10,17 +10,17 @@ module Recaptcha
|
|
10
10
|
raise(RecaptchaError, "SSL is now always true. Please remove 'ssl' from your calls to recaptcha_tags.")
|
11
11
|
end
|
12
12
|
|
13
|
-
|
13
|
+
site_key = options[:site_key] || Recaptcha.configuration.site_key!
|
14
14
|
|
15
15
|
script_url = Recaptcha.configuration.api_server_url
|
16
16
|
script_url += "?hl=#{options[:hl]}" unless options[:hl].to_s == ""
|
17
|
-
fallback_uri = "#{script_url.chomp('.js')}/fallback?k=#{
|
17
|
+
fallback_uri = "#{script_url.chomp('.js')}/fallback?k=#{site_key}"
|
18
18
|
|
19
19
|
data_attributes = [:theme, :type, :callback, :expired_callback, :size]
|
20
20
|
data_attributes = options.each_with_object({}) do |(k, v), a|
|
21
21
|
a[k] = v if data_attributes.include?(k)
|
22
22
|
end
|
23
|
-
data_attributes[:sitekey] =
|
23
|
+
data_attributes[:sitekey] = site_key
|
24
24
|
tag_attributes = data_attributes.map { |k, v| %(data-#{k.to_s.tr('_', '-')}="#{v}") }.join(" ")
|
25
25
|
|
26
26
|
if id = options[:id]
|
@@ -15,7 +15,7 @@ module Recaptcha
|
|
15
15
|
# Your are able to customize all attributes listed below. All values have
|
16
16
|
# sensitive default and will very likely not need to be changed.
|
17
17
|
#
|
18
|
-
# Please note that the
|
18
|
+
# Please note that the site and secret key for the reCAPTCHA API Access
|
19
19
|
# have no useful default value. The keys may be set via the Shell enviroment
|
20
20
|
# or using this configuration. Settings within this configuration always take
|
21
21
|
# precedence.
|
@@ -23,27 +23,27 @@ module Recaptcha
|
|
23
23
|
# Setting the keys with this Configuration
|
24
24
|
#
|
25
25
|
# Recaptcha.configure do |config|
|
26
|
-
# config.
|
27
|
-
# config.
|
26
|
+
# config.site_key = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy'
|
27
|
+
# config.secret_key = '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx'
|
28
28
|
# end
|
29
29
|
#
|
30
30
|
class Configuration
|
31
|
-
attr_accessor :skip_verify_env, :
|
31
|
+
attr_accessor :skip_verify_env, :secret_key, :site_key, :proxy, :handle_timeouts_gracefully, :hostname
|
32
32
|
|
33
33
|
def initialize #:nodoc:
|
34
34
|
@skip_verify_env = %w[test cucumber]
|
35
35
|
@handle_timeouts_gracefully = HANDLE_TIMEOUTS_GRACEFULLY
|
36
36
|
|
37
|
-
@
|
38
|
-
@
|
37
|
+
@secret_key = ENV['RECAPTCHA_SECRET_KEY']
|
38
|
+
@site_key = ENV['RECAPTCHA_SITE_KEY']
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
42
|
-
|
41
|
+
def secret_key!
|
42
|
+
secret_key || raise(RecaptchaError, "No secret key specified.")
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
46
|
-
|
45
|
+
def site_key!
|
46
|
+
site_key || raise(RecaptchaError, "No site key specified.")
|
47
47
|
end
|
48
48
|
|
49
49
|
def api_server_url
|
data/lib/recaptcha/verify.rb
CHANGED
@@ -62,11 +62,11 @@ module Recaptcha
|
|
62
62
|
private
|
63
63
|
|
64
64
|
def recaptcha_verify_via_api_call(request, recaptcha_response, options)
|
65
|
-
|
65
|
+
secret_key = options[:secret_key] || Recaptcha.configuration.secret_key!
|
66
66
|
remote_ip = (request.respond_to?(:remote_ip) && request.remote_ip) || (env && env['REMOTE_ADDR'])
|
67
67
|
|
68
68
|
verify_hash = {
|
69
|
-
"secret" =>
|
69
|
+
"secret" => secret_key,
|
70
70
|
"remoteip" => remote_ip.to_s,
|
71
71
|
"response" => recaptcha_response
|
72
72
|
}
|
data/lib/recaptcha/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recaptcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason L Perry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
186
|
version: '0'
|
187
187
|
requirements: []
|
188
188
|
rubyforge_project:
|
189
|
-
rubygems_version: 2.5.1
|
189
|
+
rubygems_version: 2.4.5.1
|
190
190
|
signing_key:
|
191
191
|
specification_version: 4
|
192
192
|
summary: Helpers for the reCAPTCHA API
|