recaptcha 5.14.0 → 5.16.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 +7 -0
- data/README.md +4 -2
- data/lib/recaptcha/helpers.rb +3 -3
- data/lib/recaptcha/version.rb +1 -1
- data/lib/recaptcha.rb +12 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66a204367215f4ea083958e3f322fc7f2955e7481c09a5cadb1f57cf3acd187e
|
4
|
+
data.tar.gz: b6e7c0417b4d81bd0e7f15f7837968fbf65096e5d4a6286e297f1bbc030b7744
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c9162ae165cfb00d6ed03f91ef832e90e6bc357cfc31ee71a1a52311910fb183eb40a50967fa04f729243924c1fc9defad7d2030353ccc895b31e7bdb28e210
|
7
|
+
data.tar.gz: 8da70c71cb13ce29d7ddfa956795dc2bdcff53ea8aeaa64ad6495e5b4cfa40d82bfd90d9870220173a955e095346ba8f6e451364278af5887e4360b6d5601e07
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
## Next
|
2
2
|
|
3
|
+
## 5.16.0
|
4
|
+
* Allow usage of `options[:turbo]` as well as `options[:turbolinks]` for `recaptcha_v3`
|
5
|
+
|
6
|
+
## 5.15.0
|
7
|
+
* Add 3.2 to the list of Ruby CI versions
|
8
|
+
* Add ability to submit verify_recaptcha via POST with JSON Body with `options[:json] = true`
|
9
|
+
|
3
10
|
## 5.14.0
|
4
11
|
* drop json dependency
|
5
12
|
|
data/README.md
CHANGED
@@ -181,6 +181,7 @@ Some of the options available:
|
|
181
181
|
| `:response` | Custom response parameter. (default: `params['g-recaptcha-response-data']`)
|
182
182
|
| `: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`)
|
183
183
|
| `:env` | Current environment. The request to verify will be skipped if the environment is specified in configuration under `skip_verify_env`
|
184
|
+
| `:json` | Boolean; defaults to false; if true, will submit the verification request by POST with the request data in JSON
|
184
185
|
|
185
186
|
|
186
187
|
### `invisible_recaptcha_tags`
|
@@ -418,7 +419,7 @@ but only accepts the following options:
|
|
418
419
|
| Option | Description |
|
419
420
|
|---------------------|-------------|
|
420
421
|
| `:site_key` | Override site API key |
|
421
|
-
| `:action` | The name of the [reCAPTCHA action](https://developers.google.com/recaptcha/docs/v3#actions). Actions may only contain alphanumeric characters and
|
422
|
+
| `:action` | The name of the [reCAPTCHA action](https://developers.google.com/recaptcha/docs/v3#actions). Actions are not case-sensitive and may only contain alphanumeric characters, slashes, and underscores, and must not be user-specific. |
|
422
423
|
| `:nonce` | Optional. Sets nonce attribute for script. Can be generated via `SecureRandom.base64(32)`. (default: `nil`) |
|
423
424
|
| `:callback` | Name of callback function to call with the token. When `element` is `:input`, this defaults to a function named `setInputWithRecaptchaResponseTokenFor#{sanitize_action(action)}` that sets the value of the hidden input to the token. |
|
424
425
|
| `:id` | Specify a unique `id` attribute for the `<input>` element if using `element: :input`. (default: `"g-recaptcha-response-data-"` + `action`) |
|
@@ -426,7 +427,8 @@ but only accepts the following options:
|
|
426
427
|
| `:script` | Same as setting both `:inline_script` and `:external_script`. (default: `true`). |
|
427
428
|
| `:inline_script` | If `true`, adds an inline script tag that calls `grecaptcha.execute` for the given `site_key` and `action` and calls the `callback` with the resulting response token. Pass `false` if you want to handle calling `grecaptcha.execute` yourself. (default: `true`) |
|
428
429
|
| `:element` | The element to render, if any (default: `:input`)<br/>`:input`: Renders a hidden `<input type="hidden">` tag. The value of this will be set to the response token by the default `setInputWithRecaptchaResponseTokenFor{action}` callback.<br/>`false`: Doesn't render any tag. You'll have to add a custom callback that does something with the token. |
|
429
|
-
| `:
|
430
|
+
| `:turbo` | If `true`, calls the js function which executes reCAPTCHA after all the dependencies have been loaded. This cannot be used with the js param `:onload`. This makes reCAPTCHAv3 usable with turbo. |
|
431
|
+
| `:turbolinks` | Alias of `:turbo`. Will be deprecated soon. |
|
430
432
|
| `:ignore_no_element` | If `true`, adds null element checker for forms that can be removed from the page by javascript like modals with forms. (default: true) |
|
431
433
|
|
432
434
|
[JavaScript resource (api.js) parameters](https://developers.google.com/recaptcha/docs/invisible#js_param):
|
data/lib/recaptcha/helpers.rb
CHANGED
@@ -12,7 +12,7 @@ module Recaptcha
|
|
12
12
|
action = options.delete(:action) || raise(Recaptcha::RecaptchaError, 'action is required')
|
13
13
|
id = options.delete(:id) || "g-recaptcha-response-data-#{dasherize_action(action)}"
|
14
14
|
name = options.delete(:name) || "g-recaptcha-response-data[#{action}]"
|
15
|
-
|
15
|
+
turbo = options.delete(:turbo) || options.delete(:turbolinks)
|
16
16
|
options[:render] = site_key
|
17
17
|
options[:script_async] ||= false
|
18
18
|
options[:script_defer] ||= false
|
@@ -24,11 +24,11 @@ module Recaptcha
|
|
24
24
|
end
|
25
25
|
options[:class] = "g-recaptcha-response #{options[:class]}"
|
26
26
|
|
27
|
-
if
|
27
|
+
if turbo
|
28
28
|
options[:onload] = recaptcha_v3_execute_function_name(action)
|
29
29
|
end
|
30
30
|
html, tag_attributes = components(options)
|
31
|
-
if
|
31
|
+
if turbo
|
32
32
|
html << recaptcha_v3_onload_script(site_key, action, callback, id, options)
|
33
33
|
elsif recaptcha_v3_inline_script?(options)
|
34
34
|
html << recaptcha_v3_inline_script(site_key, action, callback, id, options)
|
data/lib/recaptcha/version.rb
CHANGED
data/lib/recaptcha.rb
CHANGED
@@ -98,7 +98,7 @@ module Recaptcha
|
|
98
98
|
verify_hash = { 'secret' => secret_key, 'response' => response }
|
99
99
|
verify_hash['remoteip'] = options[:remote_ip] if options.key?(:remote_ip)
|
100
100
|
|
101
|
-
reply = api_verification_free(verify_hash, timeout: options[:timeout])
|
101
|
+
reply = api_verification_free(verify_hash, timeout: options[:timeout], json: options[:json])
|
102
102
|
success = reply['success'].to_s == 'true' &&
|
103
103
|
hostname_valid?(reply['hostname'], options[:hostname]) &&
|
104
104
|
action_valid?(reply['action'], options[:action]) &&
|
@@ -152,11 +152,18 @@ module Recaptcha
|
|
152
152
|
instance
|
153
153
|
end
|
154
154
|
|
155
|
-
def self.api_verification_free(verify_hash, timeout: nil)
|
156
|
-
|
157
|
-
|
155
|
+
def self.api_verification_free(verify_hash, timeout: nil, json: false)
|
156
|
+
if json
|
157
|
+
uri = URI.parse(configuration.verify_url)
|
158
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
159
|
+
request['Content-Type'] = 'application/json; charset=utf-8'
|
160
|
+
request.body = JSON.generate(verify_hash)
|
161
|
+
else
|
162
|
+
query = URI.encode_www_form(verify_hash)
|
163
|
+
uri = URI.parse("#{configuration.verify_url}?#{query}")
|
164
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
165
|
+
end
|
158
166
|
http_instance = http_client_for(uri: uri, timeout: timeout)
|
159
|
-
request = Net::HTTP::Get.new(uri.request_uri)
|
160
167
|
JSON.parse(http_instance.request(request).body)
|
161
168
|
end
|
162
169
|
|
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: 5.
|
4
|
+
version: 5.16.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: 2023-
|
11
|
+
date: 2023-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mocha
|