mikras_utils 0.5.1 → 0.7.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5f3f5143ea3be29ccbdf96438b10ff7f2f59808ca6648065e5c743be051909f
|
4
|
+
data.tar.gz: 9b61802622cbaa60b2a597a477c625f4c5c2fc0d81d0a9f6e2523e1aec0abe68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 931288e3bf45321e92f6245da259948768cf7f4289250c6089e96cd70fe54324f3dcdfdd8668ae22d1f5e76d7b66b5ff4cee89243058faab2baafe6fffcb43de
|
7
|
+
data.tar.gz: bb6bdf8753f2761015a88effa7345435d0177fffdb16523e5d579b2ec24427e856064a9b5e6610d4eaf0ce2752d2120fe602c1a545720d149ec8b32018c0d805
|
@@ -33,12 +33,13 @@ module MkAcl
|
|
33
33
|
insert into acl_portal.acl_tables (
|
34
34
|
schema_name, table_name, domain,
|
35
35
|
parent_schema_name, parent_table_name, parent_link_field,
|
36
|
-
acl_link_fields, acl)
|
36
|
+
triggers, acl_link_fields, acl)
|
37
37
|
values (
|
38
38
|
'#{app_schema}', '#{table}', #{conn.quote_value(table.domain)},
|
39
39
|
#{PgConn.quote_value(table.parent && table.app_schema)},
|
40
40
|
#{PgConn.quote_value(table.parent)},
|
41
41
|
#{PgConn.quote_value(table.parent_link_field)},
|
42
|
+
#{table.triggers},
|
42
43
|
#{PgConn.quote_value(table.references.values.map(&:last), elem_type: 'text')},
|
43
44
|
#{table.acl || 'false'})
|
44
45
|
returning id as "table_id"
|
@@ -44,31 +44,35 @@ module MkAcl
|
|
44
44
|
|
45
45
|
def parse_tables(spec, tables)
|
46
46
|
for table_name, actions in tables
|
47
|
-
acl = actions.key?(:acl) ? actions.delete(:acl) : true
|
48
47
|
parent = actions.delete(:parent)
|
49
48
|
domain = actions.delete(:domain)
|
50
|
-
|
49
|
+
triggers = actions.key?(:triggers) ? actions.delete(:triggers) : true
|
50
|
+
acl = actions.key?(:acl) ? actions.delete(:acl) : true
|
51
|
+
table = Table.new(spec, table_name, domain, parent, triggers, acl)
|
51
52
|
parse_actions(table, actions)
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
55
56
|
def parse_actions(table, actions)
|
56
57
|
for action_name, rules in actions
|
57
|
-
constrain?(action_name, :insert, :select, :update, :delete, :attach) or
|
58
|
+
constrain?(action_name, :insert, :select, :update, :delete, :attach, :detach) or
|
58
59
|
error "Illegal action '#{action_name}'"
|
59
|
-
constrain?(rules, String, Array, Hash) or
|
60
|
-
error "Illegal value for #{action} action '#{rules}'"
|
61
|
-
action = Action.new(table, action_name)
|
62
|
-
|
63
|
-
# Normalize rules
|
64
|
-
case rules
|
65
|
-
when Hash
|
66
|
-
rules = [rules]
|
67
|
-
when String
|
68
|
-
rules = [{ roles: rules }]
|
69
|
-
end
|
70
60
|
|
71
|
-
|
61
|
+
for real_action_name in (action_name == :attach ? [:attach, :detach] : [action_name])
|
62
|
+
constrain?(rules, String, Array, Hash) or
|
63
|
+
error "Illegal value for #{action_name} action '#{rules}'"
|
64
|
+
action = Action.new(table, real_action_name)
|
65
|
+
|
66
|
+
# Normalize rules
|
67
|
+
case rules
|
68
|
+
when Hash
|
69
|
+
rules = [rules]
|
70
|
+
when String
|
71
|
+
rules = [{ roles: rules }]
|
72
|
+
end
|
73
|
+
|
74
|
+
parse_rules(action, rules)
|
75
|
+
end
|
72
76
|
end
|
73
77
|
end
|
74
78
|
|
@@ -69,6 +69,9 @@ module MkAcl
|
|
69
69
|
# the analyzer
|
70
70
|
attr_accessor :domain
|
71
71
|
|
72
|
+
# True if the portal object triggers should be active on the table
|
73
|
+
attr_accessor :triggers
|
74
|
+
|
72
75
|
# SQL to create the ACL for a table. No ACL if false, default ACL if nil
|
73
76
|
attr_accessor :acl
|
74
77
|
|
@@ -84,7 +87,7 @@ module MkAcl
|
|
84
87
|
# Hash from action name to action object
|
85
88
|
attr_reader :actions
|
86
89
|
|
87
|
-
def initialize(spec, name, domain, parent_name, acl)
|
90
|
+
def initialize(spec, name, domain, parent_name, triggers, acl)
|
88
91
|
@spec = spec
|
89
92
|
@references = {}
|
90
93
|
@name = name.to_s
|
@@ -93,6 +96,7 @@ module MkAcl
|
|
93
96
|
@parent_name = parent_name
|
94
97
|
@parent_link_fields = []
|
95
98
|
@domain = domain
|
99
|
+
@triggers = triggers
|
96
100
|
@acl = acl
|
97
101
|
@actions = {}
|
98
102
|
@spec.send :attach_table, self
|
@@ -113,6 +117,7 @@ module MkAcl
|
|
113
117
|
for action_name in %w(insert select update delete)
|
114
118
|
actions[action_name]&.dump
|
115
119
|
end
|
120
|
+
puts "triggers: #{triggers}"
|
116
121
|
case acl
|
117
122
|
when false; puts "acl: false"
|
118
123
|
when true;
|
@@ -171,7 +176,7 @@ module MkAcl
|
|
171
176
|
attr_accessor :filter # Goes into the postgres policy, may be nil
|
172
177
|
attr_accessor :assert # Goes into the postgres trigger, may be nil
|
173
178
|
attr_accessor :fields # Only used for insert and update, nil otherwise
|
174
|
-
attr_accessor :tables # Only used for attach, nil otherwise
|
179
|
+
attr_accessor :tables # Only used for attach and detach, nil otherwise
|
175
180
|
attr_reader :ordinal
|
176
181
|
|
177
182
|
# admin, internal, etc.
|
data/lib/mikras_utils/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mikras_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Claus Rasmussen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-01-
|
11
|
+
date: 2025-01-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg_conn
|