validates_captcha 0.9.6 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
== 0.9.7 (June 1, 2010)
|
2
|
+
|
3
|
+
* Allow an individual secret to be set for SymmetricEncryptor::Simple.
|
4
|
+
|
5
|
+
|
1
6
|
== 0.9.6 (October 30, 2009)
|
2
7
|
|
3
8
|
* Do not make captcha_challenge and captcha_solution attr_accessible. Instead overwrite AR#attributes= so they can be mass assigned.
|
data/README.rdoc
CHANGED
@@ -5,7 +5,7 @@ ActiveRecord's validation mechanism and providing helpers for ActionController
|
|
5
5
|
and ActionView.
|
6
6
|
|
7
7
|
RDoc documentation (including this README as start page) can be found at
|
8
|
-
http://m4n.github.com/validates_captcha. Validates Captcha was first
|
8
|
+
http://m4n.github.com/validates_captcha . Validates Captcha was first
|
9
9
|
announced {here}[http://m4n.github.com/2009/09/28/introducing-validates-captcha.html].
|
10
10
|
|
11
11
|
By default, question/answer captcha challenges are used, but you can also switch
|
@@ -6,6 +6,11 @@ module ValidatesCaptcha
|
|
6
6
|
# It internally uses ActiveSupport's MessageEncryptor to do the string
|
7
7
|
# encryption/decryption.
|
8
8
|
#
|
9
|
+
# To give each Rails instance the same secret key, put the following in an
|
10
|
+
# initializer:
|
11
|
+
#
|
12
|
+
# ValidatesCaptcha::SymmetricEncryptor::Simple.secret = 'bd66e2479b5...'
|
13
|
+
#
|
9
14
|
# You can implement your own symmetric encryptor by creating a class
|
10
15
|
# that conforms to the method definitions of the example below and
|
11
16
|
# assign an instance of it to
|
@@ -30,10 +35,22 @@ module ValidatesCaptcha
|
|
30
35
|
#
|
31
36
|
# Please note: The #decrypt method should return +nil+ if decryption fails.
|
32
37
|
class Simple
|
33
|
-
|
38
|
+
@@secret = ::ActiveSupport::SecureRandom.hex(64)
|
39
|
+
|
40
|
+
def self.secret #:nodoc:
|
41
|
+
@@secret
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.secret=(secret) #:nodoc:
|
45
|
+
@@secret = secret
|
46
|
+
end
|
47
|
+
|
48
|
+
def secret #:nodoc:
|
49
|
+
@@secret
|
50
|
+
end
|
34
51
|
|
35
52
|
def initialize #:nodoc:
|
36
|
-
@symmetric_encryptor = ::ActiveSupport::MessageEncryptor.new(
|
53
|
+
@symmetric_encryptor = ::ActiveSupport::MessageEncryptor.new(secret)
|
37
54
|
end
|
38
55
|
|
39
56
|
# Encrypts a cleartext string.
|
@@ -3,6 +3,27 @@ require 'test_helper'
|
|
3
3
|
SE = ValidatesCaptcha::SymmetricEncryptor::Simple
|
4
4
|
|
5
5
|
class SymmetricEncryptorTest < ValidatesCaptcha::TestCase
|
6
|
+
test "defines a class level #secret method" do
|
7
|
+
assert_respond_to SE, :secret
|
8
|
+
end
|
9
|
+
|
10
|
+
test "defines an instance level #secret method" do
|
11
|
+
assert_respond_to SE.new, :secret
|
12
|
+
end
|
13
|
+
|
14
|
+
test "defines a class level #secret= method" do
|
15
|
+
assert_respond_to SE, :secret=
|
16
|
+
end
|
17
|
+
|
18
|
+
test "#secret method's return value should equal the value set using the #secret= method" do
|
19
|
+
old_secret = SE.secret
|
20
|
+
|
21
|
+
SE.secret = 'abc'
|
22
|
+
assert_equal 'abc', SE.secret
|
23
|
+
|
24
|
+
SE.secret = old_secret
|
25
|
+
end
|
26
|
+
|
6
27
|
test "defines an instance level #encrypt method" do
|
7
28
|
assert_respond_to SE.new, :encrypt
|
8
29
|
end
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validates_captcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 53
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 9
|
9
|
+
- 7
|
10
|
+
version: 0.9.7
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Martin Andert
|
@@ -9,29 +15,41 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date:
|
18
|
+
date: 2010-06-01 00:00:00 +02:00
|
13
19
|
default_executable:
|
14
20
|
dependencies:
|
15
21
|
- !ruby/object:Gem::Dependency
|
16
22
|
name: actionpack
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
20
26
|
requirements:
|
21
27
|
- - ">="
|
22
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 7
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 3
|
33
|
+
- 2
|
23
34
|
version: 2.3.2
|
24
|
-
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
25
37
|
- !ruby/object:Gem::Dependency
|
26
38
|
name: activerecord
|
27
|
-
|
28
|
-
|
29
|
-
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
30
42
|
requirements:
|
31
43
|
- - ">="
|
32
44
|
- !ruby/object:Gem::Version
|
45
|
+
hash: 7
|
46
|
+
segments:
|
47
|
+
- 2
|
48
|
+
- 3
|
49
|
+
- 2
|
33
50
|
version: 2.3.2
|
34
|
-
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
35
53
|
description: "A captcha verification approach for Rails apps, directly integrated into ActiveRecord\xE2\x80\x99s validation mechanism and providing helpers for ActionController and ActionView."
|
36
54
|
email: martin@mehringen.de
|
37
55
|
executables: []
|
@@ -79,7 +97,7 @@ licenses: []
|
|
79
97
|
post_install_message:
|
80
98
|
rdoc_options:
|
81
99
|
- --title
|
82
|
-
- Validates Captcha 0.9.
|
100
|
+
- Validates Captcha 0.9.7
|
83
101
|
- --main
|
84
102
|
- README.rdoc
|
85
103
|
- --line-numbers
|
@@ -89,21 +107,27 @@ rdoc_options:
|
|
89
107
|
require_paths:
|
90
108
|
- lib
|
91
109
|
required_ruby_version: !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
92
111
|
requirements:
|
93
112
|
- - ">="
|
94
113
|
- !ruby/object:Gem::Version
|
114
|
+
hash: 3
|
115
|
+
segments:
|
116
|
+
- 0
|
95
117
|
version: "0"
|
96
|
-
version:
|
97
118
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
98
120
|
requirements:
|
99
121
|
- - ">="
|
100
122
|
- !ruby/object:Gem::Version
|
123
|
+
hash: 3
|
124
|
+
segments:
|
125
|
+
- 0
|
101
126
|
version: "0"
|
102
|
-
version:
|
103
127
|
requirements: []
|
104
128
|
|
105
129
|
rubyforge_project: validatecaptcha
|
106
|
-
rubygems_version: 1.3.
|
130
|
+
rubygems_version: 1.3.7
|
107
131
|
signing_key:
|
108
132
|
specification_version: 3
|
109
133
|
summary: Captcha verification for Rails using ActiveRecord's validation mechanism
|