invisible_captcha 0.12.1 → 0.12.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Appraisals +2 -2
- data/CHANGELOG.md +5 -0
- data/gemfiles/rails_6.0.gemfile +1 -1
- data/lib/invisible_captcha/controller_ext.rb +4 -10
- data/lib/invisible_captcha/version.rb +1 -1
- data/spec/controllers_spec.rb +14 -1
- 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: 5011fee9db065c86faf1507c11e0d3000ad61e19d05e7102e8bcf3750abcd52f
|
4
|
+
data.tar.gz: bd104ffe4aeb3436c1d365a293c66f80d9d2e42c543b009ea596ac83d9a84db2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1c5608b8671bfef9edfec01531f575fe3a83c12a00dd72090a772686f2fef56ab6436e323dc7ca7daa1b82d30764ca03a2f89d6727145f593d377d1c057fe51
|
7
|
+
data.tar.gz: 811827be3f2a2bd4a18a1004377605c8db09c1279658371d2191e27226afd6557235c8747a5c39ec82a65bc443bb4590dcced9fff96d8be4fba946d21a07a50d
|
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
+
## [0.12.2]
|
6
|
+
|
7
|
+
- Allow new timestamp to be set during `on_timestamp_spam` callback (#53)
|
8
|
+
|
5
9
|
## [0.12.1]
|
6
10
|
|
7
11
|
- Clear timestamp stored in `session[:invisible_captcha_timestamp]` (#50)
|
@@ -97,6 +101,7 @@ All notable changes to this project will be documented in this file.
|
|
97
101
|
|
98
102
|
- First version of controller filters
|
99
103
|
|
104
|
+
[0.12.2]: https://github.com/markets/invisible_captcha/compare/v0.12.1...v0.12.2
|
100
105
|
[0.12.1]: https://github.com/markets/invisible_captcha/compare/v0.12.0...v0.12.1
|
101
106
|
[0.12.0]: https://github.com/markets/invisible_captcha/compare/v0.11.0...v0.12.0
|
102
107
|
[0.11.0]: https://github.com/markets/invisible_captcha/compare/v0.10.0...v0.11.0
|
data/gemfiles/rails_6.0.gemfile
CHANGED
@@ -22,8 +22,6 @@ module InvisibleCaptcha
|
|
22
22
|
elsif honeypot_spam?(options)
|
23
23
|
on_spam(options)
|
24
24
|
end
|
25
|
-
|
26
|
-
clear_session
|
27
25
|
end
|
28
26
|
|
29
27
|
def on_timestamp_spam(options = {})
|
@@ -55,15 +53,15 @@ module InvisibleCaptcha
|
|
55
53
|
|
56
54
|
return false unless enabled
|
57
55
|
|
58
|
-
|
56
|
+
@invisible_captcha_timestamp ||= session.delete(:invisible_captcha_timestamp)
|
59
57
|
|
60
58
|
# Consider as spam if timestamp not in session, cause that means the form was not fetched at all
|
61
|
-
unless
|
59
|
+
unless @invisible_captcha_timestamp
|
62
60
|
warn("Invisible Captcha timestamp not found in session.")
|
63
61
|
return true
|
64
62
|
end
|
65
63
|
|
66
|
-
time_to_submit = Time.zone.now - DateTime.iso8601(
|
64
|
+
time_to_submit = Time.zone.now - DateTime.iso8601(@invisible_captcha_timestamp)
|
67
65
|
threshold = options[:timestamp_threshold] || InvisibleCaptcha.timestamp_threshold
|
68
66
|
|
69
67
|
# Consider as spam if form submitted too quickly
|
@@ -72,11 +70,7 @@ module InvisibleCaptcha
|
|
72
70
|
return true
|
73
71
|
end
|
74
72
|
|
75
|
-
false
|
76
|
-
end
|
77
|
-
|
78
|
-
def clear_session
|
79
|
-
session.delete(:invisible_captcha_timestamp) if session[:invisible_captcha_timestamp]
|
73
|
+
return false
|
80
74
|
end
|
81
75
|
|
82
76
|
def honeypot_spam?(options = {})
|
data/spec/controllers_spec.rb
CHANGED
@@ -63,12 +63,25 @@ RSpec.describe InvisibleCaptcha::ControllerExt, type: :controller do
|
|
63
63
|
expect(session[:invisible_captcha_timestamp]).to be_nil
|
64
64
|
end
|
65
65
|
|
66
|
-
it '
|
66
|
+
it 'allows a custom on_timestamp_spam callback' do
|
67
67
|
switchable_put :update, id: 1, topic: { title: 'bar' }
|
68
68
|
|
69
69
|
expect(response.status).to eq(204)
|
70
70
|
end
|
71
71
|
|
72
|
+
it 'allows a new timestamp to be set in the on_timestamp_spam callback' do
|
73
|
+
@controller.singleton_class.class_eval do
|
74
|
+
def custom_timestamp_callback
|
75
|
+
session[:invisible_captcha_timestamp] = 2.seconds.from_now(Time.zone.now).iso8601
|
76
|
+
head(204)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
expect { switchable_put :update, id: 1, topic: { title: 'bar' } }
|
81
|
+
.to change { session[:invisible_captcha_timestamp] }
|
82
|
+
.to be_present
|
83
|
+
end
|
84
|
+
|
72
85
|
context 'successful submissions' do
|
73
86
|
it 'passes if submission on or after timestamp_threshold' do
|
74
87
|
sleep InvisibleCaptcha.timestamp_threshold
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: invisible_captcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marc Anguera Insa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|