zero-captcha 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 29b399f60630d69b79a68a2b1e040b84ba3d33b8
4
- data.tar.gz: 84cac48391c72ac2c20357a4b0d220cb7297124c
2
+ SHA256:
3
+ metadata.gz: 4bb96a46a3c46abad01b0b0e4281fe67e637c33e3e8068696dc90ff5b93dcca2
4
+ data.tar.gz: 98588bd93a31afda9e65ac1e16ea7e53eb77f826707a2375ff2aab1cfb8e1ebf
5
5
  SHA512:
6
- metadata.gz: 6430b7f31395e7dd97d25626cd3da71b65ad348b4bbf37eb7b7bbe3e6b7fbe62cfbc5c353a556a595dfedd6b8711bc7b7976864625351d1ae291262032f6ef76
7
- data.tar.gz: bc3096a5624909ea0900cb6de7c790a01b6980b382f80f3da499f3094d478996b0442d98e02657d0bbf5b04dbc905be4c098e0872295d7a4d04b71290908f736
6
+ metadata.gz: e1db16192a10b4a4b9a38dd37495a44ce5e8604776c900a33db12604a371d497de0b2ada92463297f719d28de55bbbe8d832ceda8e433c1c5c22f6360fa23d0f
7
+ data.tar.gz: c753273a0168b417ea3ea6c1b373d795db6b37c4b1725db590395024c3110be734fa051ce106a67d3c957ef22323f0e6c17c52ff49bcaaa2143ff74b077e6130
data/README.markdown CHANGED
@@ -13,7 +13,7 @@ of defense alongside honeypot captchas and/or more traditional captchas.
13
13
 
14
14
  ## Requirements
15
15
 
16
- Requires jQuery on running on the client side.
16
+ Requires Rails 5+
17
17
 
18
18
  ## Installation
19
19
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.6
@@ -26,7 +26,7 @@ module ActionView
26
26
  content_tag :div do
27
27
  hidden_field_tag(name, 'verify') +
28
28
  javascript_tag do
29
- "jQuery('input[name=#{name}]').val('#{value}')".html_safe
29
+ "document.getElementsByName('#{name}')[0].setAttribute('value', '#{value}');".html_safe
30
30
  end
31
31
  end
32
32
  end.join
data/lib/zero-captcha.rb CHANGED
@@ -2,12 +2,25 @@ require 'zero-captcha/form_tag_helper'
2
2
 
3
3
  module ZeroCaptcha
4
4
  module SpamProtection
5
+ # change this in controller by overriding `zero_captcha_fields`
6
+ # to force forms to feed through specific values
5
7
  def zero_captcha_fields
6
- { :_zc_field => '5b5cd0da3121fc53b4bc84d0c8af2e81' } # change this in controller by overriding `zero_captcha_fields`
8
+ timestamp = Time.current.to_i
9
+ return {
10
+ :_zc_field => OpenSSL::HMAC.hexdigest('sha256', Rails.application.secret_key_base, "#{timestamp}"),
11
+ :_timestamp => timestamp
12
+ }
7
13
  end
8
14
 
15
+ # change this in controller by overriding `zero_captcha_fields`
16
+ # to force forms to feed through specific values
9
17
  def protect_from_spam_with_zero_captcha
10
- head :ok if zero_captcha_fields.any? { |name, value| params[name] && params[name] != value }
18
+ if request.post?
19
+ head :ok if !params[:_timestamp]
20
+ head :ok if !params[:_zc_field]
21
+ head :ok if Time.at(params[:_timestamp].to_i) < 20.minutes.ago
22
+ head :ok if params[:_zc_field] != OpenSSL::HMAC.hexdigest('sha256', Rails.application.secret_key_base, "#{params[:_timestamp]}")
23
+ end
11
24
  end
12
25
 
13
26
  def require_zero_captcha
data/zero-captcha.gemspec CHANGED
@@ -1,11 +1,11 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = %q{zero-captcha}
4
- s.version = "0.0.5"
4
+ s.version = "0.0.6"
5
5
 
6
6
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
7
7
  s.authors = ['lunaru']
8
- s.date = %q{2014-10-25}
8
+ s.date = %q{2023-08-24}
9
9
  s.description = %q{A simple way to add zero friction captchas to Rails forms}
10
10
  s.extra_rdoc_files = [
11
11
  "LICENSE",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zero-captcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - lunaru
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-25 00:00:00.000000000 Z
11
+ date: 2023-08-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A simple way to add zero friction captchas to Rails forms
14
14
  email:
@@ -45,8 +45,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
45
45
  - !ruby/object:Gem::Version
46
46
  version: '0'
47
47
  requirements: []
48
- rubyforge_project:
49
- rubygems_version: 2.5.2
48
+ rubygems_version: 3.0.3.1
50
49
  signing_key:
51
50
  specification_version: 3
52
51
  summary: A simple way to add zero friction captchas to Rails forms