rails_admin_authorized_fields 0.1.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.editorconfig +25 -0
- data/.ruby-version +1 -1
- data/README.md +5 -1
- data/lib/rails_admin_authorized_fields/section.rb +28 -13
- data/lib/rails_admin_authorized_fields/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfc10142f5dda9f9ea86cf24a2e53ce73ffbcb8a
|
4
|
+
data.tar.gz: c76f3e89d0a435f250d48d97d92d82c9767c34e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccab6dc93d869fd9f355aa21da604c2799e75568211992cef35cb9180cf1f4d0aae24311b9a5438857796a68143b659f07804221dcb657ae6fa4c42d32c79ab4
|
7
|
+
data.tar.gz: 3d260de5a2ab2a616480fa20675d49a3f3382b56ab9572d1588079d00caba4e1f75f73de91c4e2537c49b7e1f41973c969685ef4988dfb45dda9f565a7305845
|
data/.editorconfig
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
root = true
|
2
|
+
|
3
|
+
[*]
|
4
|
+
end_of_line = lf
|
5
|
+
insert_final_newline = true
|
6
|
+
trim_trailing_whitespace = true
|
7
|
+
tab_width = 2
|
8
|
+
indent_style = space
|
9
|
+
indent_size = 2
|
10
|
+
|
11
|
+
[**.bat]
|
12
|
+
end_of_line = crlf
|
13
|
+
|
14
|
+
[**.min.*]
|
15
|
+
indent_style = ignore
|
16
|
+
trim_trailing_whitespace = false
|
17
|
+
insert_final_newline = ignore
|
18
|
+
|
19
|
+
[*.slim]
|
20
|
+
insert_final_newline = false
|
21
|
+
trim_trailing_whitespace = false
|
22
|
+
|
23
|
+
[*.txt]
|
24
|
+
insert_final_newline = false
|
25
|
+
trim_trailing_whitespace = false
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.2
|
data/README.md
CHANGED
@@ -47,10 +47,14 @@ You can also use ```unauthorized_fields``` section in opposite of ```authorized_
|
|
47
47
|
field :text_slug
|
48
48
|
end
|
49
49
|
|
50
|
-
Note: all fields are ```authorized``` by default.
|
50
|
+
Note: all fields are not ```authorized``` by default if any rules present.
|
51
51
|
|
52
52
|
TODO: just a small changes needed to make ```authorized_fields``` section overridable in subsection (list, edit)
|
53
53
|
|
54
|
+
## Changelog
|
55
|
+
|
56
|
+
0.1.0 - changed default authorized logic. In 0.0.3 all fields were authorized by default. In 0.1.0 fields unauthorized when authorized_fields or unauthorized_fields sections are present.
|
57
|
+
|
54
58
|
## Contributing
|
55
59
|
|
56
60
|
1. Fork it
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module RailsAdminAuthorizedFields
|
2
|
-
module
|
2
|
+
module AuthorizedFieldsSection
|
3
3
|
def initialize(parent)
|
4
4
|
@allow_rules, @deny_rules = {}, {}
|
5
5
|
|
@@ -32,18 +32,23 @@ module RailsAdminAuthorizedFields
|
|
32
32
|
|
33
33
|
def visible_fields
|
34
34
|
return super if bindings.nil?
|
35
|
-
|
36
|
-
super.select do |field|
|
37
|
-
authorized = true
|
38
35
|
|
36
|
+
super.select do |field|
|
39
37
|
rules = field.section.field_authorization_rules(field.name)
|
40
38
|
|
41
|
-
|
42
|
-
authorized
|
43
|
-
|
39
|
+
if field.section.plugin_included?
|
40
|
+
authorized = rules[:allow].any? || rules[:deny].any?
|
41
|
+
|
42
|
+
rules[:allow].each do |rule|
|
43
|
+
authorized &= instance_eval(&rule)
|
44
|
+
end
|
45
|
+
|
46
|
+
rules[:deny].each do |rule|
|
47
|
+
authorized &= !instance_eval(&rule)
|
48
|
+
end
|
44
49
|
|
45
|
-
|
46
|
-
authorized
|
50
|
+
else
|
51
|
+
authorized = true
|
47
52
|
end
|
48
53
|
|
49
54
|
authorized
|
@@ -51,9 +56,19 @@ module RailsAdminAuthorizedFields
|
|
51
56
|
end
|
52
57
|
|
53
58
|
protected
|
54
|
-
|
59
|
+
|
60
|
+
def plugin_included?( descendant = nil )
|
61
|
+
result = @allow_rules.any? || @deny_rules.any?
|
62
|
+
|
63
|
+
return result if result
|
64
|
+
return false if @parent.nil?
|
65
|
+
return false if self == descendant
|
66
|
+
|
67
|
+
@parent.plugin_included?( self )
|
68
|
+
end
|
69
|
+
|
55
70
|
def field_authorization_rules(name)
|
56
|
-
{
|
71
|
+
{
|
57
72
|
allow: extract_rules(name, :allow_rules),
|
58
73
|
deny: extract_rules(name, :deny_rules),
|
59
74
|
}
|
@@ -64,7 +79,7 @@ module RailsAdminAuthorizedFields
|
|
64
79
|
|
65
80
|
return rules[name] || [] if rules.any?
|
66
81
|
return [] if @parent.nil?
|
67
|
-
return [] if self == descendant
|
82
|
+
return [] if self == descendant
|
68
83
|
|
69
84
|
@parent.extract_rules(name, kind, self)
|
70
85
|
end
|
@@ -77,7 +92,7 @@ module RailsAdmin
|
|
77
92
|
module Sections
|
78
93
|
# Configuration of the show view for a new object
|
79
94
|
class Base
|
80
|
-
prepend RailsAdminAuthorizedFields::
|
95
|
+
prepend RailsAdminAuthorizedFields::AuthorizedFieldsSection
|
81
96
|
end
|
82
97
|
end
|
83
98
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_admin_authorized_fields
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Malykh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails_admin
|
@@ -59,6 +59,7 @@ executables: []
|
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
+
- ".editorconfig"
|
62
63
|
- ".gitignore"
|
63
64
|
- ".ruby-gemset"
|
64
65
|
- ".ruby-version"
|
@@ -90,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
91
|
version: '0'
|
91
92
|
requirements: []
|
92
93
|
rubyforge_project:
|
93
|
-
rubygems_version: 2.
|
94
|
+
rubygems_version: 2.4.6
|
94
95
|
signing_key:
|
95
96
|
specification_version: 4
|
96
97
|
summary: Simplified authorization rules for rails_admin fields
|