recaptcha 5.13.1 → 5.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5f8e49184cd3c0a7faab777fc3f65ed6b85f12e6dbdccf92d348380b67b99e9
4
- data.tar.gz: 2ae58417d087559999a5f94d19aa56790fb8589f7f49107bdd9e2d9f451f4c82
3
+ metadata.gz: addd45d783c834ffbc2253f3b7df793762ffb839617315d6cfd17e7d5abec519
4
+ data.tar.gz: 1795b9d183326d23f408b5dd2b595531ff504885797012aa51953c6efc73a29d
5
5
  SHA512:
6
- metadata.gz: 53aaceab8e0d55c84c612b8a62ae7dc77f58052f20ddec8674e79b9735104558584d0dfbdde3172f36227af2a8c87c3ea031a12ba5928b7873b1559aa97f4ba1
7
- data.tar.gz: 9ccae1a7fdfe7e3afe1b7ac80814688a840e695e13af749e7d576fa8c74a3c3fe27dcdff26fae5790c5cf391594853d29259be0a63dfa5d119cf6476ff2dc808
6
+ metadata.gz: ddccc592d5d0ecdf7bae96d6a68ea29085dcdbfad9b346ae761a50d8b5b4c9f5337946e4e4374af4a1f74a2d8efd1e90e7a517f933f89f71a0cf3a1add44e701
7
+ data.tar.gz: 9b3fc098f10c2a53798adaebca95b60a0e54b6188275dd388afd3fb160ff881caf7724e57c9063478c08d7b8e3f268e952aefc413bf2e3e2ab4bdf7c13a4b0a4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  ## Next
2
2
 
3
+ ## 5.15.0
4
+ * Add 3.2 to the list of Ruby CI versions
5
+ * Add ability to submit verify_recaptcha via POST with JSON Body with `options[:json] = true`
6
+
7
+ ## 5.14.0
8
+ * drop json dependency
9
+
3
10
  ## 5.13.1
4
11
  * Permit actions as symbol
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`
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Recaptcha
4
- VERSION = '5.13.1'
4
+ VERSION = '5.15.0'
5
5
  end
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
- query = URI.encode_www_form(verify_hash)
157
- uri = URI.parse("#{configuration.verify_url}?#{query}")
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,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recaptcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.13.1
4
+ version: 5.15.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-04-17 00:00:00.000000000 Z
11
+ date: 2023-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: json
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: mocha
29
15
  requirement: !ruby/object:Gem::Requirement