cancancan 2.3.0 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cancancan.gemspec +6 -5
- data/init.rb +2 -0
- data/lib/cancan/ability/actions.rb +2 -0
- data/lib/cancan/ability/rules.rb +20 -9
- data/lib/cancan/ability/strong_parameter_support.rb +41 -0
- data/lib/cancan/ability.rb +54 -24
- data/lib/cancan/class_matcher.rb +30 -0
- data/lib/cancan/conditions_matcher.rb +72 -18
- data/lib/cancan/config.rb +101 -0
- data/lib/cancan/controller_additions.rb +5 -2
- data/lib/cancan/controller_resource.rb +7 -1
- data/lib/cancan/controller_resource_builder.rb +2 -0
- data/lib/cancan/controller_resource_finder.rb +2 -0
- data/lib/cancan/controller_resource_loader.rb +4 -0
- data/lib/cancan/controller_resource_name_finder.rb +2 -0
- data/lib/cancan/controller_resource_sanitizer.rb +2 -0
- data/lib/cancan/exceptions.rb +18 -2
- data/lib/cancan/matchers.rb +7 -2
- data/lib/cancan/model_adapters/abstract_adapter.rb +22 -1
- data/lib/cancan/model_adapters/active_record_4_adapter.rb +26 -25
- data/lib/cancan/model_adapters/active_record_5_adapter.rb +17 -26
- data/lib/cancan/model_adapters/active_record_adapter.rb +130 -15
- data/lib/cancan/model_adapters/conditions_extractor.rb +7 -7
- data/lib/cancan/model_adapters/conditions_normalizer.rb +49 -0
- data/lib/cancan/model_adapters/default_adapter.rb +2 -0
- data/lib/cancan/model_adapters/sti_normalizer.rb +47 -0
- data/lib/cancan/model_adapters/strategies/base.rb +40 -0
- data/lib/cancan/model_adapters/strategies/joined_alias_each_rule_as_exists_subquery.rb +93 -0
- data/lib/cancan/model_adapters/strategies/joined_alias_exists_subquery.rb +31 -0
- data/lib/cancan/model_adapters/strategies/left_join.rb +11 -0
- data/lib/cancan/model_adapters/strategies/subquery.rb +18 -0
- data/lib/cancan/model_additions.rb +6 -2
- data/lib/cancan/parameter_validators.rb +9 -0
- data/lib/cancan/relevant.rb +29 -0
- data/lib/cancan/rule.rb +67 -23
- data/lib/cancan/rules_compressor.rb +3 -0
- data/lib/cancan/sti_detector.rb +12 -0
- data/lib/cancan/unauthorized_message_resolver.rb +24 -0
- data/lib/cancan/version.rb +3 -1
- data/lib/cancan.rb +11 -0
- data/lib/cancancan.rb +2 -0
- data/lib/generators/cancan/ability/ability_generator.rb +3 -1
- data/lib/generators/cancan/ability/templates/ability.rb +9 -9
- metadata +37 -24
- data/lib/cancan/model_adapters/can_can/model_adapters/active_record_adapter/joins.rb +0 -39
metadata
CHANGED
@@ -1,46 +1,52 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cancancan
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessandro Rodi (Renuo AG)
|
8
8
|
- Bryan Rite
|
9
9
|
- Ryan Bates
|
10
10
|
- Richard Wilson
|
11
|
-
autorequire:
|
11
|
+
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2023-03-05 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
|
-
name:
|
17
|
+
name: appraisal
|
18
18
|
requirement: !ruby/object:Gem::Requirement
|
19
19
|
requirements:
|
20
20
|
- - "~>"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '2.0'
|
23
|
+
- - ">="
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 2.0.0
|
23
26
|
type: :development
|
24
27
|
prerelease: false
|
25
28
|
version_requirements: !ruby/object:Gem::Requirement
|
26
29
|
requirements:
|
27
30
|
- - "~>"
|
28
31
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
32
|
+
version: '2.0'
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 2.0.0
|
30
36
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
37
|
+
name: bundler
|
32
38
|
requirement: !ruby/object:Gem::Requirement
|
33
39
|
requirements:
|
34
40
|
- - "~>"
|
35
41
|
- !ruby/object:Gem::Version
|
36
|
-
version: 0
|
42
|
+
version: '2.0'
|
37
43
|
type: :development
|
38
44
|
prerelease: false
|
39
45
|
version_requirements: !ruby/object:Gem::Requirement
|
40
46
|
requirements:
|
41
47
|
- - "~>"
|
42
48
|
- !ruby/object:Gem::Version
|
43
|
-
version: 0
|
49
|
+
version: '2.0'
|
44
50
|
- !ruby/object:Gem::Dependency
|
45
51
|
name: rake
|
46
52
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,25 +88,19 @@ dependencies:
|
|
82
88
|
- !ruby/object:Gem::Version
|
83
89
|
version: 3.2.0
|
84
90
|
- !ruby/object:Gem::Dependency
|
85
|
-
name:
|
91
|
+
name: rubocop
|
86
92
|
requirement: !ruby/object:Gem::Requirement
|
87
93
|
requirements:
|
88
94
|
- - "~>"
|
89
95
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
91
|
-
- - ">="
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: 2.0.0
|
96
|
+
version: 1.31.1
|
94
97
|
type: :development
|
95
98
|
prerelease: false
|
96
99
|
version_requirements: !ruby/object:Gem::Requirement
|
97
100
|
requirements:
|
98
101
|
- - "~>"
|
99
102
|
- !ruby/object:Gem::Version
|
100
|
-
version:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 2.0.0
|
103
|
+
version: 1.31.1
|
104
104
|
description: Simple authorization solution for Rails. All permissions are stored in
|
105
105
|
a single location.
|
106
106
|
email: alessandro.rodi@renuo.ch
|
@@ -114,7 +114,10 @@ files:
|
|
114
114
|
- lib/cancan/ability.rb
|
115
115
|
- lib/cancan/ability/actions.rb
|
116
116
|
- lib/cancan/ability/rules.rb
|
117
|
+
- lib/cancan/ability/strong_parameter_support.rb
|
118
|
+
- lib/cancan/class_matcher.rb
|
117
119
|
- lib/cancan/conditions_matcher.rb
|
120
|
+
- lib/cancan/config.rb
|
118
121
|
- lib/cancan/controller_additions.rb
|
119
122
|
- lib/cancan/controller_resource.rb
|
120
123
|
- lib/cancan/controller_resource_builder.rb
|
@@ -128,12 +131,22 @@ files:
|
|
128
131
|
- lib/cancan/model_adapters/active_record_4_adapter.rb
|
129
132
|
- lib/cancan/model_adapters/active_record_5_adapter.rb
|
130
133
|
- lib/cancan/model_adapters/active_record_adapter.rb
|
131
|
-
- lib/cancan/model_adapters/can_can/model_adapters/active_record_adapter/joins.rb
|
132
134
|
- lib/cancan/model_adapters/conditions_extractor.rb
|
135
|
+
- lib/cancan/model_adapters/conditions_normalizer.rb
|
133
136
|
- lib/cancan/model_adapters/default_adapter.rb
|
137
|
+
- lib/cancan/model_adapters/sti_normalizer.rb
|
138
|
+
- lib/cancan/model_adapters/strategies/base.rb
|
139
|
+
- lib/cancan/model_adapters/strategies/joined_alias_each_rule_as_exists_subquery.rb
|
140
|
+
- lib/cancan/model_adapters/strategies/joined_alias_exists_subquery.rb
|
141
|
+
- lib/cancan/model_adapters/strategies/left_join.rb
|
142
|
+
- lib/cancan/model_adapters/strategies/subquery.rb
|
134
143
|
- lib/cancan/model_additions.rb
|
144
|
+
- lib/cancan/parameter_validators.rb
|
145
|
+
- lib/cancan/relevant.rb
|
135
146
|
- lib/cancan/rule.rb
|
136
147
|
- lib/cancan/rules_compressor.rb
|
148
|
+
- lib/cancan/sti_detector.rb
|
149
|
+
- lib/cancan/unauthorized_message_resolver.rb
|
137
150
|
- lib/cancan/version.rb
|
138
151
|
- lib/cancancan.rb
|
139
152
|
- lib/generators/cancan/ability/USAGE
|
@@ -142,8 +155,9 @@ files:
|
|
142
155
|
homepage: https://github.com/CanCanCommunity/cancancan
|
143
156
|
licenses:
|
144
157
|
- MIT
|
145
|
-
metadata:
|
146
|
-
|
158
|
+
metadata:
|
159
|
+
funding_uri: https://github.com/sponsors/coorasse
|
160
|
+
post_install_message:
|
147
161
|
rdoc_options: []
|
148
162
|
require_paths:
|
149
163
|
- lib
|
@@ -158,9 +172,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
172
|
- !ruby/object:Gem::Version
|
159
173
|
version: '0'
|
160
174
|
requirements: []
|
161
|
-
|
162
|
-
|
163
|
-
signing_key:
|
175
|
+
rubygems_version: 3.3.7
|
176
|
+
signing_key:
|
164
177
|
specification_version: 4
|
165
178
|
summary: Simple authorization solution for Rails.
|
166
179
|
test_files: []
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module CanCan
|
2
|
-
module ModelAdapters
|
3
|
-
module ActiveRecordAdapter
|
4
|
-
module Joins
|
5
|
-
# Returns the associations used in conditions for the :joins option of a search.
|
6
|
-
# See ModelAdditions#accessible_by
|
7
|
-
def joins
|
8
|
-
joins_hash = {}
|
9
|
-
@rules.reverse.each do |rule|
|
10
|
-
merge_joins(joins_hash, rule.associations_hash)
|
11
|
-
end
|
12
|
-
clean_joins(joins_hash) unless joins_hash.empty?
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
# Removes empty hashes and moves everything into arrays.
|
18
|
-
def clean_joins(joins_hash)
|
19
|
-
joins = []
|
20
|
-
joins_hash.each do |name, nested|
|
21
|
-
joins << (nested.empty? ? name : { name => clean_joins(nested) })
|
22
|
-
end
|
23
|
-
joins
|
24
|
-
end
|
25
|
-
|
26
|
-
# Takes two hashes and does a deep merge.
|
27
|
-
def merge_joins(base, add)
|
28
|
-
add.each do |name, nested|
|
29
|
-
if base[name].is_a?(Hash)
|
30
|
-
merge_joins(base[name], nested) unless nested.empty?
|
31
|
-
else
|
32
|
-
base[name] = nested
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|