rucaptcha 0.2.3 → 0.2.5

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
  SHA1:
3
- metadata.gz: d09e398b9cff324f96e3a24709509f5c8131b01e
4
- data.tar.gz: 801d27ee2ad5eca42265d1d1b88f2cced13ec832
3
+ metadata.gz: 83dddcf03d3e8acd1121b05f1336d520dc5af592
4
+ data.tar.gz: 68308146916e90db9ff32b4f02906988528812b2
5
5
  SHA512:
6
- metadata.gz: e72e2878241245b06ac94d3ab3aa8023c1376c2f7913fd2a9e02f9001ec0207a660365da6bb31922ef92e0c5c7ee608f85aba628a2316fb1ba2b1b9f49f8a2c5
7
- data.tar.gz: 284fcd0c6c6bbc54122386642e8fa77bc8a2613616c7d6f2992ff08de55a525d621ea6539417969a0c200e0a9fadbbcc63467acfd9329c113fcc7769d885cd9f
6
+ metadata.gz: b79383bab6530fb996518f8faa08e67fae2bb8c43de138a5e874ebe4866a5df7e901ea7a5e4475eb50b6d060d2e61470b18d3add84fbe336f0e9184762a1b2dc
7
+ data.tar.gz: 7d43f1c0416454ebbc8bc19c012e90712d41acae249a77c59eaec6be1a02a4eff4c45e3f2940e22c035d8d5193351c7a11b18d2331c0b52bbc3ed87eb175a49f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ 0.2.5
2
+ -----
3
+
4
+ - Add `session[:_rucaptcha]` expire time, for protect Rails CookieSession Replay Attack.
5
+ - Captcha input field disable autocomplete, and set field type as `email` for shown correct keyboard on mobile view.
6
+
1
7
  0.2.3
2
8
  -----
3
9
 
@@ -7,11 +7,19 @@ module RuCaptcha
7
7
  end
8
8
 
9
9
  def generate_rucaptcha
10
- session[:_rucaptcha] = RuCaptcha::Captcha.random_chars
10
+ session[:_rucaptcha] = RuCaptcha::Captcha.random_chars
11
+ session[:_rucaptcha_at] = Time.now.to_i
12
+
11
13
  RuCaptcha::Captcha.create(session[:_rucaptcha])
12
14
  end
13
15
 
14
16
  def verify_rucaptcha?(resource = nil)
17
+ rucaptcha_at = session[:_rucaptcha_at].to_i
18
+ # Captcha chars in Session expire in 2 minutes
19
+ if rucaptcha_at.blank? || (Time.now.to_i - rucaptcha_at) > 120
20
+ return false
21
+ end
22
+
15
23
  right = params[:_rucaptcha].present? && session[:_rucaptcha].present? &&
16
24
  params[:_rucaptcha].downcase.strip == session[:_rucaptcha]
17
25
  if resource && resource.respond_to?(:errors)
@@ -1,3 +1,3 @@
1
1
  module RuCaptcha
2
- VERSION = '0.2.3'
2
+ VERSION = '0.2.5'
3
3
  end
@@ -2,6 +2,8 @@ module RuCaptcha
2
2
  module ViewHelpers
3
3
  def rucaptcha_input_tag(opts = {})
4
4
  opts[:name] = '_rucaptcha'
5
+ opts[:type] = 'email'
6
+ opts[:autocomplete] = 'off'
5
7
  tag(:input, opts)
6
8
  end
7
9
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rucaptcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Lee