protector 0.4.1 → 0.5.1

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: e15f3c1ee4395642576ca756587e32adc363b461
4
- data.tar.gz: f18f5e9a33d866c903e7f8be1db3425daa97ad67
3
+ metadata.gz: 260447659aefa18d02fe15039a7f33ba3d8c39e7
4
+ data.tar.gz: 82d8f778b44ed5b10063d9b527df7b841181315d
5
5
  SHA512:
6
- metadata.gz: 61613c761e8e2193ed7d87521e1469af9fb9997f7bf0dc52f247302f179df8bbeee6f2eef3d636447d0cc250b706b819af88b2493e02e1c56b85f0a831e92eeb
7
- data.tar.gz: 18fd32ceb5907097d297a61f73db4a2b0aa5fe306d606cd735e6796ac49fec7852758912a6745d5052e4e69f8ef864b6405c3fb9a907f78e6f81b31adac4a450
6
+ metadata.gz: f4b8e1b04ccef3bc2650f3b210fded9a83306a792cd60909ccef8c8aacb73b6a56d083506d619ae10d9baf97c4e2e4b2979f8518aa49bfa592ef15748d0253b5
7
+ data.tar.gz: 377952116d10b58e86e0c151ac89aa2bbf7e41cd94ee756e14497dd0cf2f11303d7bcdafa6380d557e4577400ced122f08c521766f38de0eb91188f7bc04d960
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ spec/internal/log
data/Appraisals CHANGED
@@ -8,6 +8,19 @@ appraise "AR_4" do
8
8
  gem "activerecord-jdbcsqlite3-adapter", platform: :jruby, github: "jruby/activerecord-jdbc-adapter"
9
9
  end
10
10
 
11
+ appraise "Rails_3.2" do
12
+ gem "combustion", github: 'pat/combustion'
13
+ gem "rails", "3.2.13"
14
+ gem "strong_parameters"
15
+ gem "activerecord-jdbcsqlite3-adapter", platform: :jruby, github: "jruby/activerecord-jdbc-adapter"
16
+ end
17
+
18
+ appraise "Rails_4" do
19
+ gem "combustion", github: 'pat/combustion'
20
+ gem "rails", "4.0.0"
21
+ gem "activerecord-jdbcsqlite3-adapter", platform: :jruby, github: "jruby/activerecord-jdbc-adapter"
22
+ end
23
+
11
24
  appraise "Sequel" do
12
25
  gem "sequel", "3.30.0"
13
26
  end
data/Gemfile CHANGED
@@ -5,8 +5,6 @@ gem 'rake'
5
5
  gem 'colored'
6
6
  gem 'pry'
7
7
  gem 'rspec'
8
- gem 'guard'
9
- gem 'guard-rspec'
10
8
 
11
9
  gem 'appraisal'
12
10
 
data/README.md CHANGED
@@ -20,7 +20,8 @@ We are working hard to extend the list with:
20
20
 
21
21
  Protector is an extension and therefore hides deeply inside your ORM library making itself compatible to the most gems you use. Sometimes however, you might need additional integration to take the best from it:
22
22
 
23
- * [Protector::SimpleForm](https://github.com/deversus/protector-simple_form)
23
+ * [Protector and Strong Parameters](https://github.com/inossidabile/protector/wiki/Protector-and-Strong-Parameters)
24
+ * [Protector and SimpleForm](https://github.com/inossidabile/protector/wiki/Protector-and-SimpleForm)
24
25
 
25
26
  ## Basics
26
27
 
@@ -207,9 +208,10 @@ Where "ActiveRecord" is the adapter you are about to use. It can be "Sequel", "D
207
208
 
208
209
  ## Options
209
210
 
210
- Use `Protector.option = value` to assign an option. Available options are:
211
+ Use `Protector.config.option = value` to assign an option. Available options are:
211
212
 
212
213
  * **paranoid**: makes scope management white-listed. If set to `true` will force Protector to return empty scope when no scope was given within a protection block.
214
+ * **strong_parameters**: set to `false` to disable built-in [Strong Parameters integration](https://github.com/inossidabile/protector/wiki/Protector-and-Strong-Parameters).
213
215
 
214
216
  Protector features basic Rails integration so you can assign options using `config.protector.option = value` at your `config/*.rb`.
215
217
 
@@ -10,7 +10,7 @@ GIT
10
10
  PATH
11
11
  remote: /Users/inossidabile/Repos/protector
12
12
  specs:
13
- protector (0.4.1)
13
+ protector (0.5.0)
14
14
  activesupport
15
15
  i18n
16
16
 
@@ -1,12 +1,16 @@
1
1
  GIT
2
2
  remote: git://github.com/jruby/activerecord-jdbc-adapter.git
3
- revision: 178d6177ae874a00e07f514e293eaa58d26dca5d
3
+ revision: cf50772153fbf0db5e8a4a2025da32954e625df1
4
4
  specs:
5
+ activerecord-jdbc-adapter (1.3.0.beta2)
6
+ activerecord-jdbcsqlite3-adapter (1.3.0.beta2)
7
+ activerecord-jdbc-adapter (~> 1.3.0.beta2)
8
+ jdbc-sqlite3 (~> 3.7.2)
5
9
 
6
10
  PATH
7
11
  remote: /Users/inossidabile/Repos/protector
8
12
  specs:
9
- protector (0.4.1)
13
+ protector (0.5.0)
10
14
  activesupport
11
15
  i18n
12
16
 
@@ -33,6 +37,7 @@ GEM
33
37
  rake
34
38
  arel (4.0.0)
35
39
  atomic (1.1.10)
40
+ atomic (1.1.10-java)
36
41
  builder (3.1.4)
37
42
  coderay (1.0.9)
38
43
  colored (1.2)
@@ -45,6 +50,7 @@ GEM
45
50
  thor
46
51
  diff-lcs (1.2.4)
47
52
  ffi (1.9.0)
53
+ ffi (1.9.0-java)
48
54
  formatador (0.2.4)
49
55
  guard (1.8.1)
50
56
  formatador (>= 0.2.4)
@@ -56,6 +62,7 @@ GEM
56
62
  guard (>= 1.8)
57
63
  rspec (~> 2.13)
58
64
  i18n (0.6.4)
65
+ jdbc-sqlite3 (3.7.2)
59
66
  listen (1.2.2)
60
67
  rb-fsevent (>= 0.9.3)
61
68
  rb-inotify (>= 0.9)
@@ -69,6 +76,11 @@ GEM
69
76
  coderay (~> 1.0.5)
70
77
  method_source (~> 0.8)
71
78
  slop (~> 3.4)
79
+ pry (0.9.12.2-java)
80
+ coderay (~> 1.0.5)
81
+ method_source (~> 0.8)
82
+ slop (~> 3.4)
83
+ spoon (~> 0.0)
72
84
  rake (10.1.0)
73
85
  rb-fsevent (0.9.3)
74
86
  rb-inotify (0.9.0)
@@ -91,6 +103,8 @@ GEM
91
103
  simplecov-html (~> 0.7.1)
92
104
  simplecov-html (0.7.1)
93
105
  slop (3.4.5)
106
+ spoon (0.0.4)
107
+ ffi
94
108
  sqlite3 (1.3.7)
95
109
  thor (0.18.1)
96
110
  thread_safe (0.1.0)
@@ -98,6 +112,7 @@ GEM
98
112
  tzinfo (0.3.37)
99
113
 
100
114
  PLATFORMS
115
+ java
101
116
  ruby
102
117
 
103
118
  DEPENDENCIES
@@ -0,0 +1,21 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake"
6
+ gem "colored"
7
+ gem "pry"
8
+ gem "rspec"
9
+ gem "guard"
10
+ gem "guard-rspec"
11
+ gem "appraisal"
12
+ gem "sqlite3", :platform=>:ruby
13
+ gem "jdbc-sqlite3", :platform=>:jruby, :require=>"jdbc/sqlite3"
14
+ gem "coveralls", :require=>false
15
+ gem "ruby-prof", :platform=>:ruby
16
+ gem "combustion", :github=>"pat/combustion"
17
+ gem "rails", "3.2.13"
18
+ gem "strong_parameters"
19
+ gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby, :github=>"jruby/activerecord-jdbc-adapter"
20
+
21
+ gemspec :path=>"../"
@@ -0,0 +1,196 @@
1
+ GIT
2
+ remote: git://github.com/jruby/activerecord-jdbc-adapter.git
3
+ revision: cf50772153fbf0db5e8a4a2025da32954e625df1
4
+ specs:
5
+ activerecord-jdbc-adapter (1.3.0.beta2)
6
+ activerecord-jdbcsqlite3-adapter (1.3.0.beta2)
7
+ activerecord-jdbc-adapter (~> 1.3.0.beta2)
8
+ jdbc-sqlite3 (~> 3.7.2)
9
+
10
+ GIT
11
+ remote: git://github.com/pat/combustion.git
12
+ revision: 5141f8412cff75c496692f49755d38d23e587db8
13
+ specs:
14
+ combustion (0.5.0)
15
+ activesupport (>= 3.0.0)
16
+ railties (>= 3.0.0)
17
+ thor (>= 0.14.6)
18
+
19
+ PATH
20
+ remote: /Users/inossidabile/Repos/protector
21
+ specs:
22
+ protector (0.5.0)
23
+ activesupport
24
+ i18n
25
+
26
+ GEM
27
+ remote: https://rubygems.org/
28
+ specs:
29
+ actionmailer (3.2.13)
30
+ actionpack (= 3.2.13)
31
+ mail (~> 2.5.3)
32
+ actionpack (3.2.13)
33
+ activemodel (= 3.2.13)
34
+ activesupport (= 3.2.13)
35
+ builder (~> 3.0.0)
36
+ erubis (~> 2.7.0)
37
+ journey (~> 1.0.4)
38
+ rack (~> 1.4.5)
39
+ rack-cache (~> 1.2)
40
+ rack-test (~> 0.6.1)
41
+ sprockets (~> 2.2.1)
42
+ activemodel (3.2.13)
43
+ activesupport (= 3.2.13)
44
+ builder (~> 3.0.0)
45
+ activerecord (3.2.13)
46
+ activemodel (= 3.2.13)
47
+ activesupport (= 3.2.13)
48
+ arel (~> 3.0.2)
49
+ tzinfo (~> 0.3.29)
50
+ activeresource (3.2.13)
51
+ activemodel (= 3.2.13)
52
+ activesupport (= 3.2.13)
53
+ activesupport (3.2.13)
54
+ i18n (= 0.6.1)
55
+ multi_json (~> 1.0)
56
+ appraisal (0.5.2)
57
+ bundler
58
+ rake
59
+ arel (3.0.2)
60
+ builder (3.0.4)
61
+ coderay (1.0.9)
62
+ colored (1.2)
63
+ colorize (0.5.8)
64
+ coveralls (0.6.7)
65
+ colorize
66
+ multi_json (~> 1.3)
67
+ rest-client
68
+ simplecov (>= 0.7)
69
+ thor
70
+ diff-lcs (1.2.4)
71
+ erubis (2.7.0)
72
+ ffi (1.9.0)
73
+ ffi (1.9.0-java)
74
+ formatador (0.2.4)
75
+ guard (1.8.1)
76
+ formatador (>= 0.2.4)
77
+ listen (>= 1.0.0)
78
+ lumberjack (>= 1.0.2)
79
+ pry (>= 0.9.10)
80
+ thor (>= 0.14.6)
81
+ guard-rspec (3.0.2)
82
+ guard (>= 1.8)
83
+ rspec (~> 2.13)
84
+ hike (1.2.3)
85
+ i18n (0.6.1)
86
+ jdbc-sqlite3 (3.7.2)
87
+ journey (1.0.4)
88
+ json (1.8.0)
89
+ json (1.8.0-java)
90
+ listen (1.2.2)
91
+ rb-fsevent (>= 0.9.3)
92
+ rb-inotify (>= 0.9)
93
+ rb-kqueue (>= 0.2)
94
+ lumberjack (1.0.4)
95
+ mail (2.5.4)
96
+ mime-types (~> 1.16)
97
+ treetop (~> 1.4.8)
98
+ method_source (0.8.1)
99
+ mime-types (1.23)
100
+ multi_json (1.7.7)
101
+ polyglot (0.3.3)
102
+ pry (0.9.12.2)
103
+ coderay (~> 1.0.5)
104
+ method_source (~> 0.8)
105
+ slop (~> 3.4)
106
+ pry (0.9.12.2-java)
107
+ coderay (~> 1.0.5)
108
+ method_source (~> 0.8)
109
+ slop (~> 3.4)
110
+ spoon (~> 0.0)
111
+ rack (1.4.5)
112
+ rack-cache (1.2)
113
+ rack (>= 0.4)
114
+ rack-ssl (1.3.3)
115
+ rack
116
+ rack-test (0.6.2)
117
+ rack (>= 1.0)
118
+ rails (3.2.13)
119
+ actionmailer (= 3.2.13)
120
+ actionpack (= 3.2.13)
121
+ activerecord (= 3.2.13)
122
+ activeresource (= 3.2.13)
123
+ activesupport (= 3.2.13)
124
+ bundler (~> 1.0)
125
+ railties (= 3.2.13)
126
+ railties (3.2.13)
127
+ actionpack (= 3.2.13)
128
+ activesupport (= 3.2.13)
129
+ rack-ssl (~> 1.3.2)
130
+ rake (>= 0.8.7)
131
+ rdoc (~> 3.4)
132
+ thor (>= 0.14.6, < 2.0)
133
+ rake (10.1.0)
134
+ rb-fsevent (0.9.3)
135
+ rb-inotify (0.9.0)
136
+ ffi (>= 0.5.0)
137
+ rb-kqueue (0.2.0)
138
+ ffi (>= 0.5.0)
139
+ rdoc (3.12.2)
140
+ json (~> 1.4)
141
+ rest-client (1.6.7)
142
+ mime-types (>= 1.16)
143
+ rspec (2.14.1)
144
+ rspec-core (~> 2.14.0)
145
+ rspec-expectations (~> 2.14.0)
146
+ rspec-mocks (~> 2.14.0)
147
+ rspec-core (2.14.2)
148
+ rspec-expectations (2.14.0)
149
+ diff-lcs (>= 1.1.3, < 2.0)
150
+ rspec-mocks (2.14.1)
151
+ ruby-prof (0.13.0)
152
+ simplecov (0.7.1)
153
+ multi_json (~> 1.0)
154
+ simplecov-html (~> 0.7.1)
155
+ simplecov-html (0.7.1)
156
+ slop (3.4.5)
157
+ spoon (0.0.4)
158
+ ffi
159
+ sprockets (2.2.2)
160
+ hike (~> 1.2)
161
+ multi_json (~> 1.0)
162
+ rack (~> 1.0)
163
+ tilt (~> 1.1, != 1.3.0)
164
+ sqlite3 (1.3.7)
165
+ strong_parameters (0.2.1)
166
+ actionpack (~> 3.0)
167
+ activemodel (~> 3.0)
168
+ railties (~> 3.0)
169
+ thor (0.18.1)
170
+ tilt (1.4.1)
171
+ treetop (1.4.14)
172
+ polyglot
173
+ polyglot (>= 0.3.1)
174
+ tzinfo (0.3.37)
175
+
176
+ PLATFORMS
177
+ java
178
+ ruby
179
+
180
+ DEPENDENCIES
181
+ activerecord-jdbcsqlite3-adapter!
182
+ appraisal
183
+ colored
184
+ combustion!
185
+ coveralls
186
+ guard
187
+ guard-rspec
188
+ jdbc-sqlite3
189
+ protector!
190
+ pry
191
+ rails (= 3.2.13)
192
+ rake
193
+ rspec
194
+ ruby-prof
195
+ sqlite3
196
+ strong_parameters
@@ -0,0 +1,20 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rake"
6
+ gem "colored"
7
+ gem "pry"
8
+ gem "rspec"
9
+ gem "guard"
10
+ gem "guard-rspec"
11
+ gem "appraisal"
12
+ gem "sqlite3", :platform=>:ruby
13
+ gem "jdbc-sqlite3", :platform=>:jruby, :require=>"jdbc/sqlite3"
14
+ gem "coveralls", :require=>false
15
+ gem "ruby-prof", :platform=>:ruby
16
+ gem "combustion", :github=>"pat/combustion"
17
+ gem "rails", "4.0.0"
18
+ gem "activerecord-jdbcsqlite3-adapter", :platform=>:jruby, :github=>"jruby/activerecord-jdbc-adapter"
19
+
20
+ gemspec :path=>"../"
@@ -0,0 +1,186 @@
1
+ GIT
2
+ remote: git://github.com/jruby/activerecord-jdbc-adapter.git
3
+ revision: cf50772153fbf0db5e8a4a2025da32954e625df1
4
+ specs:
5
+ activerecord-jdbc-adapter (1.3.0.beta2)
6
+ activerecord-jdbcsqlite3-adapter (1.3.0.beta2)
7
+ activerecord-jdbc-adapter (~> 1.3.0.beta2)
8
+ jdbc-sqlite3 (~> 3.7.2)
9
+
10
+ GIT
11
+ remote: git://github.com/pat/combustion.git
12
+ revision: 5141f8412cff75c496692f49755d38d23e587db8
13
+ specs:
14
+ combustion (0.5.0)
15
+ activesupport (>= 3.0.0)
16
+ railties (>= 3.0.0)
17
+ thor (>= 0.14.6)
18
+
19
+ PATH
20
+ remote: /Users/inossidabile/Repos/protector
21
+ specs:
22
+ protector (0.5.0)
23
+ activesupport
24
+ i18n
25
+
26
+ GEM
27
+ remote: https://rubygems.org/
28
+ specs:
29
+ actionmailer (4.0.0)
30
+ actionpack (= 4.0.0)
31
+ mail (~> 2.5.3)
32
+ actionpack (4.0.0)
33
+ activesupport (= 4.0.0)
34
+ builder (~> 3.1.0)
35
+ erubis (~> 2.7.0)
36
+ rack (~> 1.5.2)
37
+ rack-test (~> 0.6.2)
38
+ activemodel (4.0.0)
39
+ activesupport (= 4.0.0)
40
+ builder (~> 3.1.0)
41
+ activerecord (4.0.0)
42
+ activemodel (= 4.0.0)
43
+ activerecord-deprecated_finders (~> 1.0.2)
44
+ activesupport (= 4.0.0)
45
+ arel (~> 4.0.0)
46
+ activerecord-deprecated_finders (1.0.3)
47
+ activesupport (4.0.0)
48
+ i18n (~> 0.6, >= 0.6.4)
49
+ minitest (~> 4.2)
50
+ multi_json (~> 1.3)
51
+ thread_safe (~> 0.1)
52
+ tzinfo (~> 0.3.37)
53
+ appraisal (0.5.2)
54
+ bundler
55
+ rake
56
+ arel (4.0.0)
57
+ atomic (1.1.10)
58
+ atomic (1.1.10-java)
59
+ builder (3.1.4)
60
+ coderay (1.0.9)
61
+ colored (1.2)
62
+ colorize (0.5.8)
63
+ coveralls (0.6.7)
64
+ colorize
65
+ multi_json (~> 1.3)
66
+ rest-client
67
+ simplecov (>= 0.7)
68
+ thor
69
+ diff-lcs (1.2.4)
70
+ erubis (2.7.0)
71
+ ffi (1.9.0)
72
+ ffi (1.9.0-java)
73
+ formatador (0.2.4)
74
+ guard (1.8.1)
75
+ formatador (>= 0.2.4)
76
+ listen (>= 1.0.0)
77
+ lumberjack (>= 1.0.2)
78
+ pry (>= 0.9.10)
79
+ thor (>= 0.14.6)
80
+ guard-rspec (3.0.2)
81
+ guard (>= 1.8)
82
+ rspec (~> 2.13)
83
+ hike (1.2.3)
84
+ i18n (0.6.4)
85
+ jdbc-sqlite3 (3.7.2)
86
+ listen (1.2.2)
87
+ rb-fsevent (>= 0.9.3)
88
+ rb-inotify (>= 0.9)
89
+ rb-kqueue (>= 0.2)
90
+ lumberjack (1.0.4)
91
+ mail (2.5.4)
92
+ mime-types (~> 1.16)
93
+ treetop (~> 1.4.8)
94
+ method_source (0.8.1)
95
+ mime-types (1.23)
96
+ minitest (4.7.5)
97
+ multi_json (1.7.7)
98
+ polyglot (0.3.3)
99
+ pry (0.9.12.2)
100
+ coderay (~> 1.0.5)
101
+ method_source (~> 0.8)
102
+ slop (~> 3.4)
103
+ pry (0.9.12.2-java)
104
+ coderay (~> 1.0.5)
105
+ method_source (~> 0.8)
106
+ slop (~> 3.4)
107
+ spoon (~> 0.0)
108
+ rack (1.5.2)
109
+ rack-test (0.6.2)
110
+ rack (>= 1.0)
111
+ rails (4.0.0)
112
+ actionmailer (= 4.0.0)
113
+ actionpack (= 4.0.0)
114
+ activerecord (= 4.0.0)
115
+ activesupport (= 4.0.0)
116
+ bundler (>= 1.3.0, < 2.0)
117
+ railties (= 4.0.0)
118
+ sprockets-rails (~> 2.0.0)
119
+ railties (4.0.0)
120
+ actionpack (= 4.0.0)
121
+ activesupport (= 4.0.0)
122
+ rake (>= 0.8.7)
123
+ thor (>= 0.18.1, < 2.0)
124
+ rake (10.1.0)
125
+ rb-fsevent (0.9.3)
126
+ rb-inotify (0.9.0)
127
+ ffi (>= 0.5.0)
128
+ rb-kqueue (0.2.0)
129
+ ffi (>= 0.5.0)
130
+ rest-client (1.6.7)
131
+ mime-types (>= 1.16)
132
+ rspec (2.14.1)
133
+ rspec-core (~> 2.14.0)
134
+ rspec-expectations (~> 2.14.0)
135
+ rspec-mocks (~> 2.14.0)
136
+ rspec-core (2.14.2)
137
+ rspec-expectations (2.14.0)
138
+ diff-lcs (>= 1.1.3, < 2.0)
139
+ rspec-mocks (2.14.1)
140
+ ruby-prof (0.13.0)
141
+ simplecov (0.7.1)
142
+ multi_json (~> 1.0)
143
+ simplecov-html (~> 0.7.1)
144
+ simplecov-html (0.7.1)
145
+ slop (3.4.5)
146
+ spoon (0.0.4)
147
+ ffi
148
+ sprockets (2.10.0)
149
+ hike (~> 1.2)
150
+ multi_json (~> 1.0)
151
+ rack (~> 1.0)
152
+ tilt (~> 1.1, != 1.3.0)
153
+ sprockets-rails (2.0.0)
154
+ actionpack (>= 3.0)
155
+ activesupport (>= 3.0)
156
+ sprockets (~> 2.8)
157
+ sqlite3 (1.3.7)
158
+ thor (0.18.1)
159
+ thread_safe (0.1.0)
160
+ atomic
161
+ tilt (1.4.1)
162
+ treetop (1.4.14)
163
+ polyglot
164
+ polyglot (>= 0.3.1)
165
+ tzinfo (0.3.37)
166
+
167
+ PLATFORMS
168
+ java
169
+ ruby
170
+
171
+ DEPENDENCIES
172
+ activerecord-jdbcsqlite3-adapter!
173
+ appraisal
174
+ colored
175
+ combustion!
176
+ coveralls
177
+ guard
178
+ guard-rspec
179
+ jdbc-sqlite3
180
+ protector!
181
+ pry
182
+ rails (= 4.0.0)
183
+ rake
184
+ rspec
185
+ ruby-prof
186
+ sqlite3
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/inossidabile/Repos/protector
3
3
  specs:
4
- protector (0.4.1)
4
+ protector (0.5.0)
5
5
  activesupport
6
6
  i18n
7
7
 
@@ -18,6 +18,7 @@ GEM
18
18
  bundler
19
19
  rake
20
20
  atomic (1.1.10)
21
+ atomic (1.1.10-java)
21
22
  coderay (1.0.9)
22
23
  colored (1.2)
23
24
  colorize (0.5.8)
@@ -32,12 +32,12 @@ module Protector
32
32
  end
33
33
 
34
34
  unless Protector::Adapters::ActiveRecord.modern?
35
- def self.restrict!(subject)
36
- scoped.restrict!(subject)
35
+ def self.restrict!(*args)
36
+ scoped.restrict! *args
37
37
  end
38
38
  else
39
- def self.restrict!(subject)
40
- all.restrict!(subject)
39
+ def self.restrict!(*args)
40
+ all.restrict! *args
41
41
  end
42
42
  end
43
43
 
@@ -74,9 +74,16 @@ module Protector
74
74
  merge(protector_meta.relation).unrestrict!.exists? *args
75
75
  end
76
76
 
77
- def new_with_protector(*args)
78
- return new_without_protector unless protector_subject?
79
- new_without_protector.restrict!(protector_subject)
77
+ # Forwards protection subject to the new instance
78
+ def new_with_protector(*args, &block)
79
+ return new_without_protector(*args, &block) unless protector_subject?
80
+
81
+ # strong_parameters integration
82
+ if Protector.config.strong_parameters? && args.first.respond_to?(:permit)
83
+ Protector::ActiveRecord::StrongParameters::sanitize! args, true, protector_meta
84
+ end
85
+
86
+ new_without_protector(*args, &block).restrict!(protector_subject)
80
87
  end
81
88
 
82
89
  # Patches current relation to fulfill restriction and call real `exec_queries`
@@ -0,0 +1,26 @@
1
+ module Protector
2
+ module ActiveRecord
3
+ module StrongParameters
4
+ def self.sanitize!(args, is_new, meta)
5
+ if is_new
6
+ args[0] = args[0].permit *meta.access[:create].keys
7
+ else
8
+ args[0] = args[0].permit *meta.access[:update].keys
9
+ end
10
+ end
11
+
12
+ # strong_parameters integration
13
+ def sanitize_for_mass_assignment(*args)
14
+ # We check only for updation here since the creation will be handled by relation
15
+ # (see Protector::Adapters::ActiveRecord::Relation#new_with_protector)
16
+ if Protector.config.strong_parameters? && args.first.respond_to?(:permit) \
17
+ && !new_record? && protector_subject?
18
+
19
+ StrongParameters::sanitize! args, false, protector_meta
20
+ end
21
+
22
+ super
23
+ end
24
+ end
25
+ end
26
+ end
@@ -2,6 +2,7 @@ require 'protector/adapters/active_record/base'
2
2
  require 'protector/adapters/active_record/association'
3
3
  require 'protector/adapters/active_record/relation'
4
4
  require 'protector/adapters/active_record/preloader'
5
+ require 'protector/adapters/active_record/strong_parameters'
5
6
 
6
7
  module Protector
7
8
  module Adapters
@@ -17,8 +17,8 @@ module Protector
17
17
 
18
18
  module ClassMethods
19
19
  # Gets default restricted `Dataset`
20
- def restrict!(subject)
21
- dataset.clone.restrict! subject
20
+ def restrict!(*args)
21
+ dataset.clone.restrict! *args
22
22
  end
23
23
  end
24
24
 
data/lib/protector/dsl.rb CHANGED
@@ -37,7 +37,7 @@ module Protector
37
37
  # Checks whether protection with given subject
38
38
  # has the selection scope defined
39
39
  def scoped?
40
- Protector.paranoid || !!@scope_proc
40
+ Protector.config.paranoid? || !!@scope_proc
41
41
  end
42
42
 
43
43
  # @group Protection DSL
@@ -60,7 +60,7 @@ module Protector
60
60
  end
61
61
 
62
62
  def scope_proc
63
- unless Protector.paranoid
63
+ unless Protector.config.paranoid?
64
64
  @scope_proc
65
65
  else
66
66
  @scope_proc || @adapter.null_proc
@@ -239,7 +239,7 @@ module Protector
239
239
  # Assigns restriction subject
240
240
  #
241
241
  # @param [Object] subject Subject to restrict against
242
- def restrict!(subject)
242
+ def restrict!(subject=nil)
243
243
  @protector_subject = subject
244
244
  @protector_subject_set = true
245
245
  self
@@ -3,9 +3,11 @@ module Protector
3
3
  config.protector = ActiveSupport::OrderedOptions.new
4
4
 
5
5
  initializer "protector.configuration" do |app|
6
- app.config.protector.each do |key, value|
7
- Protector.send "#{key}=", value
6
+ app.config.protector.each{|k,v| Protector.config[k] = v}
7
+
8
+ if Protector::Adapters::ActiveRecord.modern?
9
+ ::ActiveRecord::Base.send(:include, Protector::ActiveRecord::StrongParameters)
8
10
  end
9
11
  end
10
12
  end
11
- end
13
+ end
@@ -1,4 +1,4 @@
1
1
  module Protector
2
2
  # Gem version
3
- VERSION = "0.4.1"
3
+ VERSION = "0.5.1"
4
4
  end
data/lib/protector.rb CHANGED
@@ -17,7 +17,11 @@ module Protector
17
17
  Protector::Adapters::Sequel
18
18
  ]
19
19
 
20
- attr_accessor :paranoid
20
+ attr_accessor :config
21
+
22
+ def paranoid=
23
+ "`Protector.paranoid = ...` is deprecated! Please change it to `Protector.config.paranoid = ...`"
24
+ end
21
25
 
22
26
  # Allows executing any code having Protector globally disabled
23
27
  def insecurely(&block)
@@ -31,6 +35,18 @@ module Protector
31
35
  ADAPTERS.each{|adapter| adapter.activate!}
32
36
  end
33
37
  end
38
+
39
+ class Config < ActiveSupport::OrderedOptions
40
+ def paranoid?
41
+ !!paranoid
42
+ end
43
+
44
+ def strong_parameters?
45
+ strong_parameters == nil || !!strong_parameters
46
+ end
47
+ end
48
+
49
+ self.config = Config.new
34
50
  end
35
51
 
36
52
  Protector.activate!
@@ -0,0 +1,4 @@
1
+ test:
2
+ adapter: <%= "jdbc" if defined? JRUBY_VERSION %>sqlite3
3
+ database: ":memory:"
4
+ verbosity: quiet
File without changes
@@ -0,0 +1,57 @@
1
+ require 'spec_helpers/boot'
2
+
3
+ if defined?(Rails)
4
+ describe Protector::Engine do
5
+ before(:all) do
6
+ Combustion.initialize! :active_record do
7
+ config.protector.paranoid = true
8
+ config.action_controller.action_on_unpermitted_parameters = :raise
9
+ end
10
+
11
+ Protector.activate!
12
+
13
+ unless Protector::Adapters::ActiveRecord.modern?
14
+ ActiveRecord::Base.send(:include, ActiveModel::ForbiddenAttributesProtection)
15
+ ActiveRecord::Base.send(:include, Protector::ActiveRecord::StrongParameters)
16
+ end
17
+ end
18
+
19
+ after(:all) do
20
+ Protector.config.paranoid = false
21
+ end
22
+
23
+ it "inherits Rails config" do
24
+ Protector.config.paranoid?.should == true
25
+ Protector.config.strong_parameters?.should == true
26
+ end
27
+
28
+ describe "strong_parameters" do
29
+ before(:all) do
30
+ load 'migrations/active_record.rb'
31
+
32
+ Dummy.instance_eval do
33
+ protect do
34
+ can :create, :string
35
+ can :update, :number
36
+ end
37
+ end
38
+ end
39
+
40
+ def params(*args)
41
+ ActionController::Parameters.new *args
42
+ end
43
+
44
+ it "creates" do
45
+ expect{ Dummy.restrict!.new params(string: 'test') }.to_not raise_error
46
+ expect{ Dummy.restrict!.new params(number: 1) }.to raise_error
47
+ end
48
+
49
+ it "updates" do
50
+ dummy = Dummy.create!
51
+
52
+ expect{ dummy.restrict!.assign_attributes params(string: 'test') }.to raise_error
53
+ expect{ dummy.restrict!.assign_attributes params(number: 1) }.to_not raise_error
54
+ end
55
+ end
56
+ end
57
+ end
@@ -1,21 +1,21 @@
1
1
  shared_context "paranoidal", paranoid: true do
2
2
  before(:all) do
3
- @paranoid_condition = Protector.paranoid
4
- Protector.paranoid = true
3
+ @paranoid_condition = Protector.config.paranoid?
4
+ Protector.config.paranoid = true
5
5
  end
6
6
 
7
7
  after(:all) do
8
- Protector.paranoid = @paranoid_condition
8
+ Protector.config.paranoid = @paranoid_condition
9
9
  end
10
10
  end
11
11
 
12
12
  shared_context "adequate", paranoid: false do
13
13
  before(:all) do
14
- @paranoid_condition = Protector.paranoid
15
- Protector.paranoid = false
14
+ @paranoid_condition = Protector.config.paranoid?
15
+ Protector.config.paranoid = false
16
16
  end
17
17
 
18
18
  after(:all) do
19
- Protector.paranoid = @paranoid_condition
19
+ Protector.config.paranoid = @paranoid_condition
20
20
  end
21
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boris Staal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-12 00:00:00.000000000 Z
11
+ date: 2013-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -61,6 +61,10 @@ files:
61
61
  - gemfiles/AR_4.gemfile.lock
62
62
  - gemfiles/Mongoid.gemfile
63
63
  - gemfiles/Mongoid.gemfile.lock
64
+ - gemfiles/Rails_3.2.gemfile
65
+ - gemfiles/Rails_3.2.gemfile.lock
66
+ - gemfiles/Rails_4.gemfile
67
+ - gemfiles/Rails_4.gemfile.lock
64
68
  - gemfiles/Sequel.gemfile
65
69
  - gemfiles/Sequel.gemfile.lock
66
70
  - lib/protector.rb
@@ -69,6 +73,7 @@ files:
69
73
  - lib/protector/adapters/active_record/base.rb
70
74
  - lib/protector/adapters/active_record/preloader.rb
71
75
  - lib/protector/adapters/active_record/relation.rb
76
+ - lib/protector/adapters/active_record/strong_parameters.rb
72
77
  - lib/protector/adapters/sequel.rb
73
78
  - lib/protector/adapters/sequel/dataset.rb
74
79
  - lib/protector/adapters/sequel/eager_graph_loader.rb
@@ -83,9 +88,12 @@ files:
83
88
  - perf/perf_helpers/boot.rb
84
89
  - perf/sequel_perf.rb
85
90
  - protector.gemspec
91
+ - spec/internal/config/database.yml
92
+ - spec/internal/db/schema.rb
86
93
  - spec/lib/adapters/active_record_spec.rb
87
94
  - spec/lib/adapters/sequel_spec.rb
88
95
  - spec/lib/dsl_spec.rb
96
+ - spec/lib/engine_spec.rb
89
97
  - spec/spec_helpers/adapters/active_record.rb
90
98
  - spec/spec_helpers/adapters/sequel.rb
91
99
  - spec/spec_helpers/boot.rb
@@ -117,9 +125,12 @@ specification_version: 4
117
125
  summary: 'Protector is a successor to the Heimdallr gem: it hits the same goals keeping
118
126
  the Ruby way'
119
127
  test_files:
128
+ - spec/internal/config/database.yml
129
+ - spec/internal/db/schema.rb
120
130
  - spec/lib/adapters/active_record_spec.rb
121
131
  - spec/lib/adapters/sequel_spec.rb
122
132
  - spec/lib/dsl_spec.rb
133
+ - spec/lib/engine_spec.rb
123
134
  - spec/spec_helpers/adapters/active_record.rb
124
135
  - spec/spec_helpers/adapters/sequel.rb
125
136
  - spec/spec_helpers/boot.rb