double_trouble 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,22 +1,20 @@
1
1
  module DoubleTrouble
2
2
  module Protection
3
- def self.included(base)
4
- base.class_eval do
5
- class_inheritable_accessor :allow_double_trouble_protection
6
- cattr_accessor :double_trouble_nonce_store
7
- cattr_accessor :double_trouble_nonce_param
8
- helper_method :protect_against_double_trouble?, :double_trouble_nonce_param, :double_trouble_form_nonce
3
+ extend ActiveSupport::Concern
9
4
 
10
- self.allow_double_trouble_protection = true
5
+ included do
6
+ class_inheritable_accessor :allow_double_trouble_protection
7
+ cattr_accessor :double_trouble_nonce_store
8
+ cattr_accessor :double_trouble_nonce_param
9
+ helper_method :protect_against_double_trouble?, :double_trouble_nonce_param, :double_trouble_form_nonce
11
10
 
12
- extend(ClassMethods)
13
- end
11
+ self.allow_double_trouble_protection = true
14
12
  end
15
13
 
16
14
  module ClassMethods
17
15
  def protect_from_double_trouble(resource_name, options = {})
18
- self.double_trouble_nonce_param ||= :form_nonce
19
- self.double_trouble_nonce_store ||= CachedNonce
16
+ self.double_trouble_nonce_param ||= :form_nonce
17
+ self.double_trouble_nonce_store ||= CachedNonce
20
18
 
21
19
  around_filter(options.slice(:only, :except)) do |controller, action_block|
22
20
  if controller.send(:protect_against_double_trouble?)
@@ -36,14 +34,15 @@ module DoubleTrouble
36
34
  end
37
35
  end
38
36
 
39
- protected
40
-
41
- def double_trouble_form_nonce
42
- ActiveSupport::SecureRandom.base64(32)
43
- end
37
+ module InstanceMethods
38
+ protected
39
+ def double_trouble_form_nonce
40
+ ActiveSupport::SecureRandom.base64(32)
41
+ end
44
42
 
45
- def protect_against_double_trouble?
46
- allow_double_trouble_protection && double_trouble_nonce_store && double_trouble_nonce_param
43
+ def protect_against_double_trouble?
44
+ allow_double_trouble_protection && double_trouble_nonce_store && double_trouble_nonce_param
45
+ end
47
46
  end
48
47
  end
49
48
  end
@@ -1,3 +1,3 @@
1
1
  module DoubleTrouble
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -5,6 +5,7 @@ require "action_controller/base"
5
5
  require "action_view"
6
6
  require "action_view/helpers/form_tag_helper"
7
7
  require "active_support/cache"
8
+ require "active_support/concern"
8
9
 
9
10
  require "double_trouble/errors"
10
11
  require "double_trouble/cached_nonce"
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: double_trouble
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
11
10
  platform: ruby
12
11
  authors:
13
12
  - "Jakub Ku\xC5\xBAma"
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-07-09 00:00:00 +02:00
17
+ date: 2010-08-25 00:00:00 +02:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -24,14 +23,12 @@ dependencies:
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
24
  none: false
26
25
  requirements:
27
- - - "="
26
+ - - ~>
28
27
  - !ruby/object:Gem::Version
29
- hash: 19
30
28
  segments:
31
- - 2
32
29
  - 3
33
- - 8
34
- version: 2.3.8
30
+ - 0
31
+ version: "3.0"
35
32
  type: :runtime
36
33
  version_requirements: *id001
37
34
  - !ruby/object:Gem::Dependency
@@ -40,9 +37,8 @@ dependencies:
40
37
  requirement: &id002 !ruby/object:Gem::Requirement
41
38
  none: false
42
39
  requirements:
43
- - - ">="
40
+ - - ~>
44
41
  - !ruby/object:Gem::Version
45
- hash: 3
46
42
  segments:
47
43
  - 2
48
44
  - 0
@@ -57,7 +53,6 @@ dependencies:
57
53
  requirements:
58
54
  - - ">="
59
55
  - !ruby/object:Gem::Version
60
- hash: 3
61
56
  segments:
62
57
  - 0
63
58
  version: "0"
@@ -72,11 +67,11 @@ extensions: []
72
67
  extra_rdoc_files: []
73
68
 
74
69
  files:
75
- - lib/double_trouble/form_tag_helper_hack.rb
76
- - lib/double_trouble/protection.rb
70
+ - lib/double_trouble/errors.rb
77
71
  - lib/double_trouble/cached_nonce.rb
72
+ - lib/double_trouble/form_tag_helper_hack.rb
78
73
  - lib/double_trouble/version.rb
79
- - lib/double_trouble/errors.rb
74
+ - lib/double_trouble/protection.rb
80
75
  - lib/double_trouble.rb
81
76
  - LICENSE
82
77
  - README.rdoc
@@ -94,7 +89,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
89
  requirements:
95
90
  - - ">="
96
91
  - !ruby/object:Gem::Version
97
- hash: 3
98
92
  segments:
99
93
  - 0
100
94
  version: "0"
@@ -103,7 +97,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
97
  requirements:
104
98
  - - ">="
105
99
  - !ruby/object:Gem::Version
106
- hash: 21
107
100
  segments:
108
101
  - 1
109
102
  - 3