mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fix support for security labels. Fixes #1457
This commit is contained in:
committed by
Dave Page
parent
a7d7577c7c
commit
3d7b40e111
@@ -269,6 +269,22 @@ class EventTriggerView(PGChildNodeView):
|
||||
status=200
|
||||
)
|
||||
|
||||
def _formatter(self, result):
|
||||
"""
|
||||
This function is ued to parse security lables
|
||||
"""
|
||||
seclabels = []
|
||||
if 'seclabels' in result and result['seclabels'] is not None:
|
||||
for sec in result['seclabels']:
|
||||
sec = re.search(r'([^=]+)=(.*$)', sec)
|
||||
seclabels.append({
|
||||
'provider': sec.group(1),
|
||||
'label': sec.group(2)
|
||||
})
|
||||
|
||||
result['seclabels'] = seclabels
|
||||
return result
|
||||
|
||||
@check_precondition
|
||||
def properties(self, gid, sid, did, etid):
|
||||
"""
|
||||
@@ -290,16 +306,8 @@ class EventTriggerView(PGChildNodeView):
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
result = res['rows'][0]
|
||||
sec_labels = []
|
||||
result = self._formatter(result)
|
||||
|
||||
if 'seclabels' in result and result['seclabels'] is not None:
|
||||
for sec in result['seclabels']:
|
||||
sec = re.search(r'([^=]+)=(.*$)', sec)
|
||||
sec_labels.append({
|
||||
'provider': sec.group(1),
|
||||
'securitylabel': sec.group(2)
|
||||
})
|
||||
result.update({"seclabels": sec_labels})
|
||||
return ajax_response(
|
||||
response=result,
|
||||
status=200
|
||||
@@ -517,6 +525,8 @@ class EventTriggerView(PGChildNodeView):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
old_data = res['rows'][0]
|
||||
old_data = self._formatter(old_data)
|
||||
|
||||
for arg in required_args:
|
||||
if arg not in data:
|
||||
data[arg] = old_data[arg]
|
||||
@@ -568,6 +578,7 @@ class EventTriggerView(PGChildNodeView):
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
result = res['rows'][0]
|
||||
result = self._formatter(result)
|
||||
|
||||
sql = render_template("/".join([self.template_path, 'create.sql']), data=result, conn=self.conn)
|
||||
sql += "\n\n"
|
||||
|
||||
@@ -2,35 +2,6 @@ define(
|
||||
['jquery', 'underscore', 'underscore.string', 'pgadmin', 'pgadmin.browser', 'alertify', 'pgadmin.browser.collection'],
|
||||
function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||
|
||||
// Extend the browser's node model class to create a security model
|
||||
var SecurityLabelModel = pgAdmin.Browser.Node.Model.extend({
|
||||
defaults: {
|
||||
provider: undefined,
|
||||
securitylabel: undefined
|
||||
},
|
||||
// Define the schema for the Security Label
|
||||
schema: [
|
||||
{id: 'provider', label:'Provider', type:'text', group: null, editable: true},
|
||||
{id: 'securitylabel', label:'Security Label', type: 'text', group:null, extraHeaderClasses: 'cellwidth-40', editable: true},
|
||||
],
|
||||
validate: function() {
|
||||
// Clear any existing errors.
|
||||
|
||||
this.errorModel.clear()
|
||||
if (_.isUndefined(this.get('provider')) || String(this.get('provider')).replace(/^\s+|\s+$/g, '') == '') {
|
||||
var msg = '{{ _('Provider cannot be empty.') }}';
|
||||
this.errorModel.set('provider',msg);
|
||||
return msg;
|
||||
}
|
||||
if (_.isUndefined(this.get('securitylabel')) || String(this.get('securitylabel')).replace(/^\s+|\s+$/g, '') == '') {
|
||||
var msg = '{{ _('Security Label cannot be empty.') }}';
|
||||
this.errorModel.set('securitylabel',msg);
|
||||
return msg;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
// Extend the browser's collection class for event trigger collection
|
||||
if (!pgBrowser.Nodes['coll-event_trigger']) {
|
||||
var databases = pgAdmin.Browser.Nodes['coll-event_trigger'] =
|
||||
@@ -145,10 +116,11 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||
},{
|
||||
id: 'when', label:'{{ _('When') }}', type: 'multiline', group: "Definition",
|
||||
},{
|
||||
id: 'providers', label: 'Security Labels', type: 'collection', group: "Security Labels",
|
||||
model: SecurityLabelModel, control: 'unique-col-collection', mode: ['edit', 'create'],
|
||||
canAdd: true, canDelete: true, uniqueCol : ['provider'],
|
||||
columns: ['provider','securitylabel']
|
||||
id: 'seclabels', label: '{{ _('Security Labels') }}',
|
||||
model: pgBrowser.SecLabelModel, editable: false, type: 'collection',
|
||||
group: '{{ _('Security') }}', mode: ['edit', 'create'],
|
||||
min_version: 90200, canAdd: true,
|
||||
canEdit: false, canDelete: true, control: 'unique-col-collection'
|
||||
}
|
||||
],
|
||||
// event trigger model data validation.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/security.macros' as SECLABEL %}
|
||||
{% if data %}
|
||||
{% if data.enabled and data.enabled != "O" %}
|
||||
ALTER EVENT TRIGGER {{ conn|qtIdent(data.name) }}
|
||||
@@ -15,10 +15,10 @@ ALTER EVENT TRIGGER {{ conn|qtIdent(data.name) }}
|
||||
COMMENT ON EVENT TRIGGER {{ conn|qtIdent(data.name) }}
|
||||
IS {{ data.comment|qtLiteral }};
|
||||
{% endif %}
|
||||
{% if data.providers and data.providers|length > 0 %}
|
||||
{% if data.seclabels and data.seclabels|length > 0 %}
|
||||
|
||||
{% for r in data.providers %}
|
||||
{{ SECLABLE.APPLY(conn, 'EVENT TRIGGER', data.name, r.provider, r.securitylabel) }}
|
||||
{% for r in data.seclabels %}
|
||||
{{ SECLABEL.APPLY(conn, 'EVENT TRIGGER', data.name, r.provider, r.label) }}
|
||||
{% endfor %}{% endif %}
|
||||
|
||||
ALTER EVENT TRIGGER {{ conn|qtIdent(data.name) }}
|
||||
|
||||
@@ -4,7 +4,7 @@ e.evtenabled AS enabled,
|
||||
e.evtfoid AS eventfuncoid, quote_ident(n.nspname) || '.' || e.evtfoid::regproc AS eventfunname,
|
||||
array_to_string(array(select quote_literal(x) from unnest(evttags) as t(x)), ', ') AS when,
|
||||
pg_catalog.obj_description(e.oid, 'pg_event_trigger') AS comment,
|
||||
(SELECT array_agg(provider || '=' || label) FROM pg_shseclabel sl1 WHERE sl1.objoid=e.oid) AS seclabels,
|
||||
(SELECT array_agg(provider || '=' || label) FROM pg_seclabel sl1 WHERE sl1.objoid=e.oid) AS seclabels,
|
||||
p.prosrc AS source, p.pronamespace AS schemaoid, l.lanname AS language
|
||||
FROM pg_event_trigger e
|
||||
LEFT OUTER JOIN pg_proc p ON p.oid=e.evtfoid
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/security.macros' as SECLABEL %}
|
||||
{% if data %}
|
||||
{% if (data.eventfunname and data.eventfunname != o_data.eventfunname) or
|
||||
(data.eventname and data.eventname != o_data.eventname) or
|
||||
@@ -37,25 +37,25 @@ ALTER EVENT TRIGGER {{ conn|qtIdent(data.name) }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if data.providers and
|
||||
data.providers|length > 0
|
||||
%}{% set seclabels = data.providers %}
|
||||
{% if data.seclabels and
|
||||
data.seclabels|length > 0
|
||||
%}{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.DROP(conn, 'EVENT TRIGGER', data.name, r.provider) }}
|
||||
{{ SECLABEL.DROP(conn, 'EVENT TRIGGER', data.name, r.provider) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.APPLY(conn, 'EVENT TRIGGER', data.name, r.provider, r.securitylabel) }}
|
||||
{{ SECLABEL.APPLY(conn, 'EVENT TRIGGER', data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.APPLY(conn, 'EVENT TRIGGER', data.name, r.provider, r.securitylabel) }}
|
||||
{{ SECLABEL.APPLY(conn, 'EVENT TRIGGER', data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -325,6 +325,19 @@ class LanguageView(PGChildNodeView):
|
||||
else:
|
||||
res['rows'][0][row['deftype']] = [priv]
|
||||
|
||||
seclabels = []
|
||||
if 'seclabels' in res['rows'][0] and res['rows'][0]['seclabels'] is not None:
|
||||
import re
|
||||
for sec in res['rows'][0]['seclabels']:
|
||||
sec = re.search(r'([^=]+)=(.*$)', sec)
|
||||
seclabels.append({
|
||||
'provider': sec.group(1),
|
||||
'label': sec.group(2)
|
||||
})
|
||||
|
||||
res['rows'][0]['seclabels'] = seclabels
|
||||
|
||||
|
||||
return ajax_response(
|
||||
response=res['rows'][0],
|
||||
status=200
|
||||
@@ -439,7 +452,7 @@ class LanguageView(PGChildNodeView):
|
||||
data[arg] = old_data[arg]
|
||||
sql = render_template("/".join([self.template_path, 'update.sql']), data=data,
|
||||
o_data=old_data, conn=self.conn)
|
||||
return sql
|
||||
return sql.strip('\n')
|
||||
except Exception as e:
|
||||
return internal_server_error(errormsg=str(e))
|
||||
|
||||
@@ -480,9 +493,33 @@ class LanguageView(PGChildNodeView):
|
||||
|
||||
# Making copy of output for future use
|
||||
old_data = dict(res['rows'][0])
|
||||
|
||||
sql = render_template("/".join([self.template_path, 'acl.sql']), lid=lid)
|
||||
status, result = self.conn.execute_dict(sql)
|
||||
if not status:
|
||||
return internal_server_error(errormsg=result)
|
||||
|
||||
for row in result['rows']:
|
||||
priv = parse_priv_from_db(row)
|
||||
if row['deftype'] in old_data:
|
||||
old_data[row['deftype']].append(priv)
|
||||
else:
|
||||
old_data[row['deftype']] = [priv]
|
||||
|
||||
seclabels = []
|
||||
if 'seclabels' in old_data and old_data['seclabels'] is not None:
|
||||
import re
|
||||
for sec in old_data['seclabels']:
|
||||
sec = re.search(r'([^=]+)=(.*$)', sec)
|
||||
seclabels.append({
|
||||
'provider': sec.group(1),
|
||||
'label': sec.group(2)
|
||||
})
|
||||
|
||||
old_data['seclabels'] = seclabels
|
||||
sql = render_template("/".join([self.template_path, 'sqlpane.sql']), data=old_data, conn=self.conn)
|
||||
|
||||
return ajax_response(response=sql)
|
||||
return ajax_response(response=sql.strip('\n'))
|
||||
|
||||
@check_precondition
|
||||
def dependents(self, gid, sid, did, lid):
|
||||
|
||||
@@ -3,8 +3,7 @@ SELECT
|
||||
array_to_string(lanacl::text[], ', ') as acl, hp.proname as lanproc,
|
||||
vp.proname as lanval, description,
|
||||
pg_get_userbyid(lan.lanowner) as lanowner, ip.proname as laninl,
|
||||
(SELECT array_agg(label) FROM pg_seclabels sl1 WHERE sl1.objoid=lan.oid) AS labels,
|
||||
(SELECT array_agg(provider) FROM pg_seclabels sl2 WHERE sl2.objoid=lan.oid) AS providers
|
||||
(SELECT array_agg(provider || '=' || label) FROM pg_seclabel sl1 WHERE sl1.objoid=lan.oid) AS seclabels
|
||||
FROM
|
||||
pg_language lan JOIN pg_proc hp ON hp.oid=lanplcallfoid
|
||||
LEFT OUTER JOIN pg_proc ip ON ip.oid=laninline
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'macros/security.macros' as SECLABEL %}
|
||||
-- Language: {{data.name}}
|
||||
|
||||
-- DROP LANGUAGE {{ conn|qtIdent(data.name) }}
|
||||
@@ -12,15 +14,29 @@ CREATE {% if data.trusted %}TRUSTED{% endif %} PROCEDURAL LANGUAGE {{ conn|qtIde
|
||||
{% endif %}
|
||||
{% if data.lanval %}
|
||||
VALIDATOR {{ conn|qtIdent(data.lanval) }}{% endif %};
|
||||
|
||||
{# ============= ALTER LANGUAGE Query ============= #}
|
||||
{# ============= ALTER LANGUAGE Query ============= #}
|
||||
{% if data.lanowner %}
|
||||
|
||||
ALTER LANGUAGE {{ conn|qtIdent(data.name) }}
|
||||
OWNER TO {{ conn|qtIdent(data.lanowner) }};
|
||||
{% endif %}
|
||||
|
||||
{# ============= Comment on LANGUAGE Query ============= #}
|
||||
{% if data.description %}
|
||||
|
||||
COMMENT ON LANGUAGE {{ conn|qtIdent(data.name) }}
|
||||
IS {{ data.description|qtLiteral }};
|
||||
{% endif %}
|
||||
{# ============= PRIVILEGES on LANGUAGE ============= #}
|
||||
{% if data.lanacl and data.lanacl|length > 0 %}
|
||||
|
||||
{% for priv in data.lanacl %}
|
||||
{{ PRIVILEGE.RESETALL(conn, 'LANGUAGE', priv.grantee, data.name) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{# ============= PRIVILEGES on LANGUAGE ============= #}
|
||||
{% if data.seclabels and data.seclabels|length > 0 %}
|
||||
|
||||
{% for r in data.seclabels %}
|
||||
{{ SECLABEL.APPLY(conn, 'PROCEDURAL LANGUAGE', data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
@@ -1,4 +1,5 @@
|
||||
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'macros/security.macros' as SECLABEL %}
|
||||
{% if data %}
|
||||
{# ============= Update language name ============= #}
|
||||
{% if data.name != o_data.name %}
|
||||
@@ -35,4 +36,27 @@ COMMENT ON LANGUAGE {{ conn|qtIdent(data.name) }}
|
||||
{{ PRIVILEGE.APPLY(conn, 'LANGUAGE', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if data.seclabels and
|
||||
data.seclabels|length > 0
|
||||
%}{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABEL.DROP(conn, 'PROCEDURAL LANGUAGE', data.name, r.provider) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABEL.APPLY(conn, 'PROCEDURAL LANGUAGE', data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABEL.APPLY(conn, 'PROCEDURAL LANGUAGE', data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
@@ -3,8 +3,7 @@ SELECT
|
||||
array_to_string(lanacl::text[], ', ') as acl, hp.proname as lanproc,
|
||||
vp.proname as lanval, description,
|
||||
pg_get_userbyid(lan.lanowner) as lanowner, ip.proname as laninl,
|
||||
(SELECT array_agg(label) FROM pg_seclabels sl1 WHERE sl1.objoid=lan.oid) AS labels,
|
||||
(SELECT array_agg(provider) FROM pg_seclabels sl2 WHERE sl2.objoid=lan.oid) AS providers
|
||||
(SELECT array_agg(provider || '=' || label) FROM pg_seclabel sl1 WHERE sl1.objoid=lan.oid) AS seclabels
|
||||
FROM
|
||||
pg_language lan JOIN pg_proc hp ON hp.oid=lanplcallfoid
|
||||
LEFT OUTER JOIN pg_proc ip ON ip.oid=laninline
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'macros/security.macros' as SECLABEL %}
|
||||
-- Language: {{data.name}}
|
||||
|
||||
-- DROP LANGUAGE {{ conn|qtIdent(data.name) }}
|
||||
@@ -12,15 +14,29 @@ CREATE {% if data.trusted %}TRUSTED{% endif %} PROCEDURAL LANGUAGE {{ conn|qtIde
|
||||
{% endif %}
|
||||
{% if data.lanval %}
|
||||
VALIDATOR {{ conn|qtIdent(data.lanval) }}{% endif %};
|
||||
|
||||
{# ============= ALTER LANGUAGE Query ============= #}
|
||||
{# ============= ALTER LANGUAGE Query ============= #}
|
||||
{% if data.lanowner %}
|
||||
|
||||
ALTER LANGUAGE {{ conn|qtIdent(data.name) }}
|
||||
OWNER TO {{ conn|qtIdent(data.lanowner) }};
|
||||
{% endif %}
|
||||
|
||||
{# ============= Comment on LANGUAGE Query ============= #}
|
||||
{% if data.description %}
|
||||
|
||||
COMMENT ON LANGUAGE {{ conn|qtIdent(data.name) }}
|
||||
IS {{ data.description|qtLiteral }};
|
||||
{% endif %}
|
||||
{# ============= PRIVILEGES on LANGUAGE ============= #}
|
||||
{% if data.lanacl and data.lanacl|length > 0 %}
|
||||
|
||||
{% for priv in data.lanacl %}
|
||||
{{ PRIVILEGE.RESETALL(conn, 'LANGUAGE', priv.grantee, data.name) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{# ============= PRIVILEGES on LANGUAGE ============= #}
|
||||
{% if data.seclabels and data.seclabels|length > 0 %}
|
||||
|
||||
{% for r in data.seclabels %}
|
||||
{{ SECLABEL.APPLY(conn, 'PROCEDURAL LANGUAGE', data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
@@ -1,4 +1,5 @@
|
||||
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'macros/security.macros' as SECLABEL %}
|
||||
{% if data %}
|
||||
{# ============= Update language name ============= #}
|
||||
{% if data.name != o_data.name %}
|
||||
@@ -35,4 +36,27 @@ COMMENT ON LANGUAGE {{ conn|qtIdent(data.name) }}
|
||||
{{ PRIVILEGE.APPLY(conn, 'LANGUAGE', priv.grantee, data.name, priv.without_grant, priv.with_grant) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if data.seclabels and
|
||||
data.seclabels|length > 0
|
||||
%}{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABEL.DROP(conn, 'PROCEDURAL LANGUAGE', data.name, r.provider) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABEL.APPLY(conn, 'PROCEDURAL LANGUAGE', data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABEL.APPLY(conn, 'PROCEDURAL LANGUAGE', data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/schemas/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% if data %}
|
||||
CREATE DOMAIN {{ conn|qtIdent(data.basensp, data.name) }}
|
||||
AS {{ conn|qtTypeIdent(data.basetype) }}{% if data.typlen %}({{data.typlen}}{% if data.precision %},{{data.precision}}{% endif %}){% endif %}{% if data.collname %}
|
||||
@@ -23,7 +23,7 @@ COMMENT ON DOMAIN {{ conn|qtIdent(data.basensp, data.name) }}
|
||||
{% if r.label and r.provider %}
|
||||
|
||||
|
||||
{{ SECLABLE.SET(conn, 'DOMAIN', data.name, r.provider, r.label, data.basensp) }}{% endif -%}
|
||||
{{ SECLABEL.SET(conn, 'DOMAIN', data.name, r.provider, r.label, data.basensp) }}{% endif -%}
|
||||
{% endfor -%}
|
||||
{% endif -%}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/schemas/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% if data %}
|
||||
{% set name = o_data.name %}
|
||||
{% if data.name %}
|
||||
@@ -43,19 +43,19 @@ ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.UNSET(conn, 'DOMAIN', name, r.provider, o_data.basensp) }}
|
||||
{{ SECLABEL.UNSET(conn, 'DOMAIN', name, r.provider, o_data.basensp) }}
|
||||
|
||||
{% endfor -%}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.SET(conn, 'DOMAIN', name, r.provider, r.label, o_data.basensp) }}
|
||||
{{ SECLABEL.SET(conn, 'DOMAIN', name, r.provider, r.label, o_data.basensp) }}
|
||||
|
||||
{% endfor -%}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.SET(conn, 'DOMAIN', name, r.provider, r.label, o_data.basensp) }}
|
||||
{{ SECLABEL.SET(conn, 'DOMAIN', name, r.provider, r.label, o_data.basensp) }}
|
||||
|
||||
{% endfor -%}
|
||||
{% endif -%}{% if data.description is defined and data.description != o_data.description %}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/schemas/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% if data %}
|
||||
CREATE DOMAIN {{ conn|qtIdent(data.basensp, data.name) }}
|
||||
AS {{ conn|qtTypeIdent(data.basetype) }}{% if data.typlen %}({{data.typlen}}{% if data.precision %},{{data.precision}}{% endif %}){% endif %}{% if data.collname and data.collname != "pg_catalog.\"default\"" %}
|
||||
@@ -29,7 +29,7 @@ COMMENT ON DOMAIN {{ conn|qtIdent(data.basensp, data.name) }}
|
||||
{% if r.label and r.provider %}
|
||||
|
||||
|
||||
{{ SECLABLE.SET(conn, 'DOMAIN', data.name, r.provider, r.label, data.basensp) }}{% endif -%}
|
||||
{{ SECLABEL.SET(conn, 'DOMAIN', data.name, r.provider, r.label, data.basensp) }}{% endif -%}
|
||||
{% endfor -%}
|
||||
{% endif -%}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ SELECT
|
||||
(SELECT
|
||||
array_agg(provider || '=' || label)
|
||||
FROM
|
||||
pg_shseclabel sl1
|
||||
pg_seclabel sl1
|
||||
WHERE
|
||||
sl1.objoid=d.oid) AS seclabels
|
||||
FROM
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/schemas/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% if data %}
|
||||
{% set name = o_data.name %}
|
||||
{% if data.name %}
|
||||
@@ -55,19 +55,19 @@ ALTER DOMAIN {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.UNSET(conn, 'DOMAIN', name, r.provider, o_data.basensp) }}
|
||||
{{ SECLABEL.UNSET(conn, 'DOMAIN', name, r.provider, o_data.basensp) }}
|
||||
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
|
||||
{{ SECLABLE.SET(conn, 'DOMAIN', name, r.provider, r.label, o_data.basensp) }}
|
||||
{{ SECLABEL.SET(conn, 'DOMAIN', name, r.provider, r.label, o_data.basensp) }}
|
||||
{% endfor %}
|
||||
{% endif -%}{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
|
||||
{{ SECLABLE.SET(conn, 'DOMAIN', name, r.provider, r.label, o_data.basensp) }}
|
||||
{{ SECLABEL.SET(conn, 'DOMAIN', name, r.provider, r.label, o_data.basensp) }}
|
||||
{% endfor %}
|
||||
{% endif -%}{% if data.description is defined and data.description != o_data.description %}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/schemas/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% if data %}
|
||||
CREATE FOREIGN TABLE {{ conn|qtIdent(data.basensp, data.name) }}(
|
||||
{% if data.columns %}
|
||||
@@ -29,7 +29,7 @@ COMMENT ON FOREIGN TABLE {{ conn|qtIdent(data.basensp, data.name) }}
|
||||
{% for r in data.seclabels %}
|
||||
{% if r.label and r.provider %}
|
||||
|
||||
{{ SECLABLE.SET(conn, 'FOREIGN TABLE', data.name, r.provider, r.label, data.basensp) }}
|
||||
{{ SECLABEL.SET(conn, 'FOREIGN TABLE', data.name, r.provider, r.label, data.basensp) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/schemas/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% if data %}
|
||||
{% set name = o_data.name %}
|
||||
{% if data.name %}
|
||||
@@ -81,19 +81,19 @@ ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.UNSET(conn, 'FOREIGN TABLE', name, r.provider, o_data.basensp) }}
|
||||
{{ SECLABEL.UNSET(conn, 'FOREIGN TABLE', name, r.provider, o_data.basensp) }}
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
|
||||
{{ SECLABLE.SET(conn, 'FOREIGN TABLE', name, r.provider, r.label, o_data.basensp) }}
|
||||
{{ SECLABEL.SET(conn, 'FOREIGN TABLE', name, r.provider, r.label, o_data.basensp) }}
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
|
||||
{{ SECLABLE.SET(conn, 'FOREIGN TABLE', name, r.provider, r.label, o_data.basensp) }}
|
||||
{{ SECLABEL.SET(conn, 'FOREIGN TABLE', name, r.provider, r.label, o_data.basensp) }}
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
{% if data.description is defined and data.description != o_data.description%}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/schemas/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{% if data %}
|
||||
CREATE FOREIGN TABLE {{ conn|qtIdent(data.basensp, data.name) }}(
|
||||
@@ -40,7 +40,7 @@ COMMENT ON FOREIGN TABLE {{ conn|qtIdent(data.basensp, data.name) }}
|
||||
{% if data.seclabels %}
|
||||
|
||||
{% for r in data.seclabels %}{% if r.label and r.provider %}
|
||||
{{ SECLABLE.SET(conn, 'FOREIGN TABLE', data.name, r.provider, r.label, data.basensp) }}
|
||||
{{ SECLABEL.SET(conn, 'FOREIGN TABLE', data.name, r.provider, r.label, data.basensp) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
@@ -4,7 +4,7 @@ SELECT
|
||||
(SELECT
|
||||
array_agg(provider || '=' || label)
|
||||
FROM
|
||||
pg_shseclabel sl1
|
||||
pg_seclabel sl1
|
||||
WHERE
|
||||
sl1.objoid=c.oid) AS seclabels
|
||||
FROM
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/schemas/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{% if data %}
|
||||
{% set name = o_data.name %}
|
||||
@@ -145,19 +145,19 @@ ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
|
||||
{{ SECLABLE.UNSET(conn, 'FOREIGN TABLE', name, r.provider, o_data.basensp) }}
|
||||
{{ SECLABEL.UNSET(conn, 'FOREIGN TABLE', name, r.provider, o_data.basensp) }}
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
|
||||
{{ SECLABLE.SET(conn, 'FOREIGN TABLE', name, r.provider, r.label, o_data.basensp) }}
|
||||
{{ SECLABEL.SET(conn, 'FOREIGN TABLE', name, r.provider, r.label, o_data.basensp) }}
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
|
||||
{{ SECLABLE.SET(conn, 'FOREIGN TABLE', name, r.provider, r.label, o_data.basensp) }}
|
||||
{{ SECLABEL.SET(conn, 'FOREIGN TABLE', name, r.provider, r.label, o_data.basensp) }}
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
{% if data.description is defined and data.description != o_data.description%}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/schemas/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{% set is_columns = [] %}
|
||||
{% if data %}
|
||||
@@ -57,7 +57,7 @@ COMMENT ON FOREIGN TABLE {{ conn|qtIdent(data.basensp, data.name) }}
|
||||
{% for r in data.seclabels %}
|
||||
{% if r.label and r.provider %}
|
||||
|
||||
{{ SECLABLE.SET(conn, 'FOREIGN TABLE', data.name, r.provider, r.label, data.basensp) }}
|
||||
{{ SECLABEL.SET(conn, 'FOREIGN TABLE', data.name, r.provider, r.label, data.basensp) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
@@ -4,7 +4,7 @@ SELECT
|
||||
(SELECT
|
||||
array_agg(provider || '=' || label)
|
||||
FROM
|
||||
pg_shseclabel sl1
|
||||
pg_seclabel sl1
|
||||
WHERE
|
||||
sl1.objoid=c.oid) AS seclabels
|
||||
{% if foid %},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/schemas/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{% if data %}
|
||||
{% set name = o_data.name %}
|
||||
@@ -157,19 +157,19 @@ ALTER FOREIGN TABLE {{ conn|qtIdent(o_data.basensp, name) }}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
|
||||
{{ SECLABLE.UNSET(conn, 'FOREIGN TABLE', name, r.provider, o_data.basensp) }}
|
||||
{{ SECLABEL.UNSET(conn, 'FOREIGN TABLE', name, r.provider, o_data.basensp) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
|
||||
{{ SECLABLE.SET(conn, 'FOREIGN TABLE', name, r.provider, r.label, o_data.basensp) }}
|
||||
{{ SECLABEL.SET(conn, 'FOREIGN TABLE', name, r.provider, r.label, o_data.basensp) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
|
||||
{{ SECLABLE.SET(conn, 'FOREIGN TABLE', name, r.provider, r.label, o_data.basensp) }}
|
||||
{{ SECLABEL.SET(conn, 'FOREIGN TABLE', name, r.provider, r.label, o_data.basensp) }}
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
{% if data.description is defined and data.description != o_data.description%}
|
||||
|
||||
@@ -307,8 +307,11 @@ function($, _, S, pgAdmin, pgBrowser, alertify) {
|
||||
id: 'seclabels', label: '{{ _('Security Labels') }}', canAdd: true,
|
||||
model: pgBrowser.SecLabelModel, type: 'collection',
|
||||
min_version: 90100, group: 'security', mode: ['edit', 'create'],
|
||||
canEdit: true, canDelete: true, uniqueCol : ['provider'],
|
||||
disabled: 'isDisabled', control: 'unique-col-collection'
|
||||
canEdit: false, canDelete: true, uniqueCol : ['provider'],
|
||||
disabled: 'isDisabled', control: 'unique-col-collection',
|
||||
visible: function() {
|
||||
return this.node_data && this.node_data._type != 'procedure';
|
||||
}
|
||||
}
|
||||
],
|
||||
validate: function()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/functions/security.macros' as SECLABLE %}
|
||||
{% import 'macros/functions/security.macros' as SECLABEL %}
|
||||
{% import 'macros/functions/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'macros/functions/variable.macros' as VARIABLE %}
|
||||
{% set is_columns = [] %}
|
||||
@@ -49,7 +49,7 @@ COMMENT ON FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func
|
||||
{% for r in data.seclabels %}
|
||||
{% if r.label and r.provider %}
|
||||
|
||||
{{ SECLABLE.SET(conn, 'FUNCTION', data.name, r.provider, r.label, data.pronamespace, data.func_args) }}
|
||||
{{ SECLABEL.SET(conn, 'FUNCTION', data.name, r.provider, r.label, data.pronamespace, data.func_args) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
|
||||
@@ -7,7 +7,7 @@ SELECT
|
||||
(SELECT
|
||||
array_agg(provider || '=' || label)
|
||||
FROM
|
||||
pg_shseclabel sl1
|
||||
pg_seclabel sl1
|
||||
WHERE
|
||||
sl1.objoid=pr.oid) AS seclabels
|
||||
FROM
|
||||
|
||||
@@ -7,7 +7,7 @@ SELECT
|
||||
(SELECT
|
||||
array_agg(provider || '=' || label)
|
||||
FROM
|
||||
pg_shseclabel sl1
|
||||
pg_seclabel sl1
|
||||
WHERE
|
||||
sl1.objoid=pr.oid) AS seclabels
|
||||
FROM
|
||||
|
||||
@@ -7,7 +7,7 @@ SELECT
|
||||
(SELECT
|
||||
array_agg(provider || '=' || label)
|
||||
FROM
|
||||
pg_shseclabel sl1
|
||||
pg_seclabel sl1
|
||||
WHERE
|
||||
sl1.objoid=pr.oid) AS seclabels
|
||||
FROM
|
||||
|
||||
@@ -7,7 +7,7 @@ SELECT
|
||||
(SELECT
|
||||
array_agg(provider || '=' || label)
|
||||
FROM
|
||||
pg_shseclabel sl1
|
||||
pg_seclabel sl1
|
||||
WHERE
|
||||
sl1.objoid=pr.oid) AS seclabels
|
||||
FROM
|
||||
|
||||
@@ -14,7 +14,7 @@ SELECT
|
||||
(SELECT
|
||||
array_agg(provider || '=' || label)
|
||||
FROM
|
||||
pg_shseclabel sl1
|
||||
pg_seclabel sl1
|
||||
WHERE
|
||||
sl1.objoid=pr.oid) AS seclabels
|
||||
FROM
|
||||
|
||||
@@ -14,7 +14,7 @@ SELECT
|
||||
(SELECT
|
||||
array_agg(provider || '=' || label)
|
||||
FROM
|
||||
pg_shseclabel sl1
|
||||
pg_seclabel sl1
|
||||
WHERE
|
||||
sl1.objoid=pr.oid) AS seclabels
|
||||
FROM
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/functions/security.macros' as SECLABLE %}
|
||||
{% import 'macros/functions/security.macros' as SECLABEL %}
|
||||
{% import 'macros/functions/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'macros/functions/variable.macros' as VARIABLE %}
|
||||
{% set is_columns = [] %}
|
||||
@@ -44,7 +44,7 @@ COMMENT ON FUNCTION {{ conn|qtIdent(data.pronamespace, data.name) }}({{data.func
|
||||
{% for r in data.seclabels %}
|
||||
{% if r.label and r.provider %}
|
||||
|
||||
{{ SECLABLE.SET(conn, 'FUNCTION', data.name, r.provider, r.label, data.pronamespace, data.func_args) }}
|
||||
{{ SECLABEL.SET(conn, 'FUNCTION', data.name, r.provider, r.label, data.pronamespace, data.func_args) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
|
||||
@@ -7,7 +7,7 @@ SELECT
|
||||
(SELECT
|
||||
array_agg(provider || '=' || label)
|
||||
FROM
|
||||
pg_shseclabel sl1
|
||||
pg_seclabel sl1
|
||||
WHERE
|
||||
sl1.objoid=pr.oid) AS seclabels
|
||||
FROM
|
||||
|
||||
@@ -7,7 +7,7 @@ SELECT
|
||||
(SELECT
|
||||
array_agg(provider || '=' || label)
|
||||
FROM
|
||||
pg_shseclabel sl1
|
||||
pg_seclabel sl1
|
||||
WHERE
|
||||
sl1.objoid=pr.oid) AS seclabels
|
||||
FROM
|
||||
|
||||
@@ -7,7 +7,7 @@ SELECT
|
||||
(SELECT
|
||||
array_agg(provider || '=' || label)
|
||||
FROM
|
||||
pg_shseclabel sl1
|
||||
pg_seclabel sl1
|
||||
WHERE
|
||||
sl1.objoid=pr.oid) AS seclabels
|
||||
FROM
|
||||
|
||||
@@ -7,7 +7,7 @@ SELECT
|
||||
(SELECT
|
||||
array_agg(provider || '=' || label)
|
||||
FROM
|
||||
pg_shseclabel sl1
|
||||
pg_seclabel sl1
|
||||
WHERE
|
||||
sl1.objoid=pr.oid) AS seclabels
|
||||
FROM
|
||||
|
||||
@@ -241,16 +241,6 @@ class SequenceView(PGChildNodeView):
|
||||
if not status:
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
sec_lbls = []
|
||||
if 'securities' in res and res['securities'] is not None:
|
||||
for sec in res['seclabels']:
|
||||
sec = re.search(r'([^=]+)=(.*$)', sec)
|
||||
sec_lbls.append({
|
||||
'provider': sec.group(1),
|
||||
'label': sec.group(2)
|
||||
})
|
||||
res['securities'] = sec_lbls
|
||||
|
||||
for row in res['rows']:
|
||||
SQL = render_template("/".join([self.template_path, 'get_def.sql']), data=row)
|
||||
status, rset1 = self.conn.execute_dict(SQL)
|
||||
@@ -264,6 +254,17 @@ class SequenceView(PGChildNodeView):
|
||||
row['cache'] = rset1['rows'][0]['cache_value']
|
||||
row['cycled'] = rset1['rows'][0]['is_cycled']
|
||||
|
||||
sec_lbls = []
|
||||
if 'securities' in row and row['securities'] is not None:
|
||||
for sec in row['securities']:
|
||||
import re
|
||||
sec = re.search(r'([^=]+)=(.*$)', sec)
|
||||
sec_lbls.append({
|
||||
'provider': sec.group(1),
|
||||
'label': sec.group(2)
|
||||
})
|
||||
row['securities'] = sec_lbls
|
||||
|
||||
SQL = render_template("/".join([self.template_path, 'acl.sql']), scid=scid, seid=seid)
|
||||
status, dataclres = self.conn.execute_dict(SQL)
|
||||
if not status:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/schemas/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{# Construct sequence name from name and schema #}
|
||||
{% set seqname=conn|qtIdent(data.schema, data.name) %}
|
||||
@@ -15,7 +15,7 @@ COMMENT ON SEQUENCE {{ seqname }}
|
||||
{% if data.securities %}
|
||||
|
||||
{% for r in data.securities %}
|
||||
{{ SECLABLE.SET(conn, 'SEQUENCE', data.name, r.provider, r.label, data.schema) }}
|
||||
{{ SECLABEL.SET(conn, 'SEQUENCE', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if data.relacl %}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/schemas/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{% if data %}
|
||||
{% if data.name != o_data.name %}
|
||||
@@ -58,17 +58,17 @@ COMMENT ON SEQUENCE {{ seqname }}
|
||||
{% set seclabels = data.securities %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.UNSET(conn, 'SEQUENCE', data.name, r.provider, schema) }}
|
||||
{{ SECLABEL.UNSET(conn, 'SEQUENCE', data.name, r.provider, schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.SET(conn, 'SEQUENCE', data.name, r.provider, r.label, schema) }}
|
||||
{{ SECLABEL.SET(conn, 'SEQUENCE', data.name, r.provider, r.label, schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.SET(conn, 'SEQUENCE', data.name, r.provider, r.label, schema) }}
|
||||
{{ SECLABEL.SET(conn, 'SEQUENCE', data.name, r.provider, r.label, schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'column/macros/security.macros' as SECLABLE %}
|
||||
{% import 'column/macros/security.macros' as SECLABEL %}
|
||||
{% import 'column/macros/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'macros/variable.macros' as VARIABLE %}
|
||||
{### Add column ###}
|
||||
@@ -33,6 +33,6 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
|
||||
{### Security Lables ###}
|
||||
{% if data.seclabels %}
|
||||
{% for r in data.seclabels %}
|
||||
{{ SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
@@ -18,7 +18,7 @@ SELECT att.attname as name, att.*, def.*, pg_catalog.pg_get_expr(def.adbin, def.
|
||||
ELSE format_type(ty.oid,att.atttypmod) END AS cltype,
|
||||
-- End pgAdmin4
|
||||
EXISTS(SELECT 1 FROM pg_constraint WHERE conrelid=att.attrelid AND contype='f' AND att.attnum=ANY(conkey)) As is_fk,
|
||||
(SELECT array_agg(provider || '=' || label) FROM pg_seclabels sl1 WHERE sl1.objoid=att.atttypid AND sl1.objsubid=0) AS seclabels,
|
||||
(SELECT array_agg(provider || '=' || label) FROM pg_seclabels sl1 WHERE WHERE sl1.objoid=att.attrelid AND sl1.objsubid=att.attnum) AS seclabels,
|
||||
(CASE WHEN (att.attnum < 1) THEN true ElSE false END) AS is_sys_column
|
||||
FROM pg_attribute att
|
||||
JOIN pg_type ty ON ty.oid=atttypid
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'column/macros/security.macros' as SECLABLE %}
|
||||
{% import 'column/macros/security.macros' as SECLABEL %}
|
||||
{% import 'column/macros/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'macros/variable.macros' as VARIABLE %}
|
||||
{### Rename column name ###}
|
||||
@@ -90,17 +90,17 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.DROP(conn, 'COLUMN', data.schema, data.table, data.name, r.provider) }}
|
||||
{{ SECLABEL.DROP(conn, 'COLUMN', data.schema, data.table, data.name, r.provider) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'column/macros/security.macros' as SECLABLE %}
|
||||
{% import 'column/macros/security.macros' as SECLABEL %}
|
||||
{% import 'column/macros/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'macros/variable.macros' as VARIABLE %}
|
||||
{### Add column ###}
|
||||
@@ -33,6 +33,6 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
|
||||
{### Security Lables ###}
|
||||
{% if data.seclabels %}
|
||||
{% for r in data.seclabels %}
|
||||
{{ SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
@@ -18,7 +18,7 @@ SELECT att.attname as name, att.*, def.*, pg_catalog.pg_get_expr(def.adbin, def.
|
||||
ELSE format_type(ty.oid,att.atttypmod) END AS cltype,
|
||||
-- End pgAdmin4
|
||||
EXISTS(SELECT 1 FROM pg_constraint WHERE conrelid=att.attrelid AND contype='f' AND att.attnum=ANY(conkey)) As is_fk,
|
||||
(SELECT array_agg(provider || '=' || label) FROM pg_seclabels sl1 WHERE sl1.objoid=att.atttypid AND sl1.objsubid=0) AS seclabels,
|
||||
(SELECT array_agg(provider || '=' || label) FROM pg_seclabels sl1 WHERE sl1.objoid=att.attrelid AND sl1.objsubid=att.attnum) AS seclabels,
|
||||
(CASE WHEN (att.attnum < 1) THEN true ElSE false END) AS is_sys_column
|
||||
FROM pg_attribute att
|
||||
JOIN pg_type ty ON ty.oid=atttypid
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'column/macros/security.macros' as SECLABLE %}
|
||||
{% import 'column/macros/security.macros' as SECLABEL %}
|
||||
{% import 'column/macros/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'macros/variable.macros' as VARIABLE %}
|
||||
{### Rename column name ###}
|
||||
@@ -89,17 +89,17 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.table)}}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.DROP(conn, 'COLUMN', data.schema, data.table, data.name, r.provider) }}
|
||||
{{ SECLABEL.DROP(conn, 'COLUMN', data.schema, data.table, data.name, r.provider) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.table, data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
@@ -1,7 +1,7 @@
|
||||
{% import 'macros/schemas/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'macros/variable.macros' as VARIABLE %}
|
||||
{% import 'column/macros/security.macros' as COLUMN_SECLABLE %}
|
||||
{% import 'column/macros/security.macros' as COLUMN_SECLABEL %}
|
||||
{% import 'column/macros/privilege.macros' as COLUMN_PRIVILEGE %}
|
||||
{% import 'table/sql/macros/constraints.macro' as CONSTRAINTS %}
|
||||
{#===========================================#}
|
||||
@@ -94,7 +94,7 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}}
|
||||
{% if data.seclabels and data.seclabels|length > 0 %}
|
||||
|
||||
{% for r in data.seclabels %}
|
||||
{{ SECLABLE.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }}
|
||||
{{ SECLABEL.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{### ACL on Table ###}
|
||||
@@ -139,7 +139,7 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}}
|
||||
{% if c.seclabels and c.seclabels|length > 0 %}
|
||||
|
||||
{% for r in c.seclabels %}
|
||||
{{ COLUMN_SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.name, c.name, r.provider, r.label) }}
|
||||
{{ COLUMN_SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.name, c.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/schemas/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'macros/variable.macros' as VARIABLE %}
|
||||
{#####################################################}
|
||||
@@ -189,12 +189,12 @@ COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }}
|
||||
{{ SECLABEL.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }}
|
||||
{{ SECLABEL.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% import 'macros/schemas/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'macros/variable.macros' as VARIABLE %}
|
||||
{% import 'column/macros/security.macros' as COLUMN_SECLABLE %}
|
||||
{% import 'column/macros/security.macros' as COLUMN_SECLABEL %}
|
||||
{% import 'column/macros/privilege.macros' as COLUMN_PRIVILEGE %}
|
||||
{% import 'table/sql/macros/constraints.macro' as CONSTRAINTS %}
|
||||
{#===========================================#}
|
||||
@@ -94,7 +94,7 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}}
|
||||
{% if data.seclabels and data.seclabels|length > 0 %}
|
||||
|
||||
{% for r in data.seclabels %}
|
||||
{{ SECLABLE.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }}
|
||||
{{ SECLABEL.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{### ACL on Table ###}
|
||||
@@ -139,7 +139,7 @@ ALTER TABLE {{conn|qtIdent(data.schema, data.name)}}
|
||||
{% if c.seclabels and c.seclabels|length > 0 %}
|
||||
|
||||
{% for r in c.seclabels %}
|
||||
{{ COLUMN_SECLABLE.APPLY(conn, 'COLUMN',data.schema, data.name, c.name, r.provider, r.label) }}
|
||||
{{ COLUMN_SECLABEL.APPLY(conn, 'COLUMN',data.schema, data.name, c.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/schemas/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'macros/variable.macros' as VARIABLE %}
|
||||
{#####################################################}
|
||||
@@ -189,12 +189,12 @@ COMMENT ON TABLE {{conn|qtIdent(data.schema, data.name)}}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }}
|
||||
{{ SECLABEL.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }}
|
||||
{{ SECLABEL.SET(conn, 'TABLE', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/security.macros' as SECLABEL %}
|
||||
{% if data %}
|
||||
{# ==== To update catalog comments ==== #}
|
||||
{% if data.description and data.description != o_data.description %}
|
||||
@@ -12,17 +12,17 @@ COMMENT ON SCHEMA {{ conn|qtIdent(o_data.name) }}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.DROP(conn, 'SCHEMA', o_data.name, r.provider) }}
|
||||
{{ SECLABEL.DROP(conn, 'SCHEMA', o_data.name, r.provider) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.APPLY(conn, 'SCHEMA', o_data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.APPLY(conn, 'SCHEMA', o_data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.APPLY(conn, 'SCHEMA', o_data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.APPLY(conn, 'SCHEMA', o_data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/security.macros' as SECLABEL %}
|
||||
{% if data %}
|
||||
{# ==== To update catalog comments ==== #}
|
||||
{% if data.description and data.description != o_data.description %}
|
||||
@@ -12,17 +12,17 @@ COMMENT ON SCHEMA {{ conn|qtIdent(o_data.name) }}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.DROP(conn, 'SCHEMA', o_data.name, r.provider) }}
|
||||
{{ SECLABEL.DROP(conn, 'SCHEMA', o_data.name, r.provider) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.APPLY(conn, 'SCHEMA', o_data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.APPLY(conn, 'SCHEMA', o_data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.APPLY(conn, 'SCHEMA', o_data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.APPLY(conn, 'SCHEMA', o_data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
@@ -11,7 +11,8 @@ SELECT
|
||||
ELSE false END AS is_sys_object,
|
||||
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'r' AND defaclnamespace = nsp.oid) AS tblacl,
|
||||
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'S' AND defaclnamespace = nsp.oid) AS seqacl,
|
||||
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'f' AND defaclnamespace = nsp.oid) AS funcacl
|
||||
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'f' AND defaclnamespace = nsp.oid) AS funcacl,
|
||||
(SELECT array_agg(provider || '=' || label) FROM pg_seclabels sl1 WHERE sl1.objoid=nsp.oid) AS seclabels
|
||||
FROM
|
||||
pg_namespace nsp
|
||||
LEFT OUTER JOIN pg_description des ON
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/security.macros' as SECLABEL %}
|
||||
{% if data %}
|
||||
{# ==== To update catalog comments ==== #}
|
||||
{% if data.description and data.description != o_data.description %}
|
||||
@@ -12,17 +12,17 @@ COMMENT ON SCHEMA {{ conn|qtIdent(o_data.name) }}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.DROP(conn, 'SCHEMA', o_data.name, r.provider) }}
|
||||
{{ SECLABEL.DROP(conn, 'SCHEMA', o_data.name, r.provider) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.APPLY(conn, 'SCHEMA', o_data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.APPLY(conn, 'SCHEMA', o_data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.APPLY(conn, 'SCHEMA', o_data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.APPLY(conn, 'SCHEMA', o_data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ SELECT
|
||||
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'r' AND defaclnamespace = nsp.oid) AS tblacl,
|
||||
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'S' AND defaclnamespace = nsp.oid) AS seqacl,
|
||||
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'f' AND defaclnamespace = nsp.oid) AS funcacl,
|
||||
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'T' AND defaclnamespace = nsp.oid) AS typeacl
|
||||
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'T' AND defaclnamespace = nsp.oid) AS typeacl,
|
||||
(SELECT array_agg(provider || '=' || label) FROM pg_seclabels sl1 WHERE sl1.objoid=nsp.oid) AS seclabels
|
||||
FROM
|
||||
pg_namespace nsp
|
||||
LEFT OUTER JOIN pg_description des ON
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/security.macros' as SECLABEL %}
|
||||
{% if data %}
|
||||
{# ==== To update catalog comments ==== #}
|
||||
{% if data.description and data.description != o_data.description %}
|
||||
@@ -12,17 +12,17 @@ COMMENT ON SCHEMA {{ conn|qtIdent(o_data.name) }}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.DROP(conn, 'SCHEMA', o_data.name, r.provider) }}
|
||||
{{ SECLABEL.DROP(conn, 'SCHEMA', o_data.name, r.provider) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.APPLY(conn, 'SCHEMA', o_data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.APPLY(conn, 'SCHEMA', o_data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.APPLY(conn, 'SCHEMA', o_data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.APPLY(conn, 'SCHEMA', o_data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/security.macros' as SECLABEL %}
|
||||
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %}
|
||||
{% if data.name %}
|
||||
|
||||
@@ -14,7 +14,8 @@ SELECT
|
||||
ELSE false END AS is_sys_object,
|
||||
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'r' AND defaclnamespace = nsp.oid) AS tblacl,
|
||||
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'S' AND defaclnamespace = nsp.oid) AS seqacl,
|
||||
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'f' AND defaclnamespace = nsp.oid) AS funcacl
|
||||
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'f' AND defaclnamespace = nsp.oid) AS funcacl,
|
||||
(SELECT array_agg(provider || '=' || label) FROM pg_seclabels sl1 WHERE sl1.objoid=nsp.oid) AS seclabels
|
||||
FROM
|
||||
pg_namespace nsp
|
||||
LEFT OUTER JOIN pg_description des ON
|
||||
|
||||
@@ -15,7 +15,8 @@ SELECT
|
||||
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'r' AND defaclnamespace = nsp.oid) AS tblacl,
|
||||
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'S' AND defaclnamespace = nsp.oid) AS seqacl,
|
||||
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'f' AND defaclnamespace = nsp.oid) AS funcacl,
|
||||
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'T' AND defaclnamespace = nsp.oid) AS typeacl
|
||||
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'T' AND defaclnamespace = nsp.oid) AS typeacl,
|
||||
(SELECT array_agg(provider || '=' || label) FROM pg_seclabels sl1 WHERE sl1.objoid=nsp.oid) AS seclabels
|
||||
FROM
|
||||
pg_namespace nsp
|
||||
LEFT OUTER JOIN pg_description des ON
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/security.macros' as SECLABEL %}
|
||||
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %}
|
||||
{% if data %}
|
||||
@@ -26,17 +26,17 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.DROP(conn, 'SCHEMA', data.name, r.provider) }}
|
||||
{{ SECLABEL.DROP(conn, 'SCHEMA', data.name, r.provider) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/security.macros' as SECLABEL %}
|
||||
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %}
|
||||
{% if data %}
|
||||
@@ -26,17 +26,17 @@ COMMENT ON SCHEMA {{ conn|qtIdent(data.name) }}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.DROP(conn, 'SCHEMA', data.name, r.provider) }}
|
||||
{{ SECLABEL.DROP(conn, 'SCHEMA', data.name, r.provider) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.APPLY(conn, 'SCHEMA', data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
@@ -418,6 +418,16 @@ class TypeView(PGChildNodeView, DataTypeReader):
|
||||
range_dict = dict(res['rows'][0])
|
||||
res.update(range_dict)
|
||||
|
||||
if 'seclabels' in copy_dict and copy_dict['seclabels'] is not None:
|
||||
sec_labels = []
|
||||
for sec in copy_dict['seclabels']:
|
||||
sec = re.search(r'([^=]+)=(.*$)', sec)
|
||||
sec_labels.append({
|
||||
'provider': sec.group(1),
|
||||
'label': sec.group(2)
|
||||
})
|
||||
res['seclabels'] = sec_labels
|
||||
|
||||
# Returning only additional properties only
|
||||
return res
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/schemas/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{## If user selected shell type then just create type template ##}
|
||||
{% if data and data.typtype == 'p' %}
|
||||
@@ -77,7 +77,7 @@ COMMENT ON TYPE {% if data.schema %}{{ conn|qtIdent(data.schema, data.name) }}{%
|
||||
|
||||
{% for r in data.seclabels %}
|
||||
{% if r.provider and r.label %}
|
||||
{{ SECLABLE.SET(conn, 'TYPE', data.name, r.provider, r.label, data.schema) }}
|
||||
{{ SECLABEL.SET(conn, 'TYPE', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
@@ -6,7 +6,7 @@ SELECT t.oid, t.typname AS name,
|
||||
description, ct.oid AS taboid,
|
||||
nsp.nspname AS schema,
|
||||
--MinimumVersion 9.1 START
|
||||
(SELECT array_agg(provider || '=' || label) FROM pg_shseclabel sl1 WHERE sl1.objoid=t.oid) AS seclabels,
|
||||
(SELECT array_agg(provider || '=' || label) FROM pg_seclabel sl1 WHERE sl1.objoid=t.oid) AS seclabels,
|
||||
-- END
|
||||
(CASE WHEN (t.oid <= {{ datlastsysoid}}::oid OR ct.oid != 0) THEN true ElSE false END) AS is_sys_type
|
||||
FROM pg_type t
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{% import 'macros/schemas/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{% if data %}
|
||||
{#======================================#}
|
||||
@@ -85,17 +85,17 @@ ALTER TYPE {{ conn|qtIdent(o_data.schema, o_data.name) }}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.UNSET(conn, 'TYPE', o_data.name, r.provider, o_data.schema) }}
|
||||
{{ SECLABEL.UNSET(conn, 'TYPE', o_data.name, r.provider, o_data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.SET(conn, 'TYPE', o_data.name, r.provider, r.label, o_data.schema) }}
|
||||
{{ SECLABEL.SET(conn, 'TYPE', o_data.name, r.provider, r.label, o_data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.SET(conn, 'TYPE', o_data.name, r.provider, r.label, o_data.schema) }}
|
||||
{{ SECLABEL.SET(conn, 'TYPE', o_data.name, r.provider, r.label, o_data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
@@ -974,6 +974,11 @@ class ViewNode(PGChildNodeView, VacuumSettings):
|
||||
return internal_server_error(errormsg=res)
|
||||
|
||||
result = res['rows'][0]
|
||||
# sending result to formtter
|
||||
frmtd_reslt = self.formatter(result)
|
||||
|
||||
# merging formated result with main result again
|
||||
result.update(frmtd_reslt)
|
||||
|
||||
# Fetch all privileges for view
|
||||
SQL = render_template("/".join(
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{# ===== Grant Permissions to User Role on Views/Tables ==== #}
|
||||
{% import 'macros/schemas/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{# We will generate Security Label SQL using macro #}
|
||||
{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABLE.SET(conn, 'MATERIALIZED VIEW', data.name, r.provider, r.label, data.schema) }}{% endfor %}{% endif %}
|
||||
{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABEL.SET(conn, 'MATERIALIZED VIEW', data.name, r.provider, r.label, data.schema) }}{% endfor %}{% endif %}
|
||||
{% if data.datacl %}{% for priv in data.datacl %}{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }}{% endfor %}{% endif %}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{# ===================== Update View ===================#}
|
||||
{% import 'macros/schemas/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{%- if data -%}
|
||||
{% set view_name = data.name if data.name else o_data.name %}
|
||||
@@ -197,17 +197,17 @@ COMMENT ON MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.UNSET(conn, 'MATERIALIZED VIEW', data.name, r.provider, data.schema) }}
|
||||
{{ SECLABEL.UNSET(conn, 'MATERIALIZED VIEW', data.name, r.provider, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.SET(conn, 'MATERIALIZED VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{{ SECLABEL.SET(conn, 'MATERIALIZED VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.SET(conn, 'MATERIALIZED VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{{ SECLABEL.SET(conn, 'MATERIALIZED VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{# ===== Grant Permissions to User Role on Views/Tables ==== #}
|
||||
{% import 'macros/schemas/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{# We will generate Security Label SQL using macro #}
|
||||
{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABLE.SET(conn, 'MATERIALIZED VIEW', data.name, r.provider, r.label, data.schema) }}{% endfor %}{% endif %}
|
||||
{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABEL.SET(conn, 'MATERIALIZED VIEW', data.name, r.provider, r.label, data.schema) }}{% endfor %}{% endif %}
|
||||
{% if data.datacl %}{% for priv in data.datacl %}{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }}{% endfor %}{% endif %}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{# ===================== Update View ===================#}
|
||||
{% import 'macros/schemas/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{%- if data -%}
|
||||
{% set view_name = data.name if data.name else o_data.name %}
|
||||
@@ -197,17 +197,17 @@ COMMENT ON MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.UNSET(conn, 'MATERIALIZED VIEW', data.name, r.provider, data.schema) }}
|
||||
{{ SECLABEL.UNSET(conn, 'MATERIALIZED VIEW', data.name, r.provider, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.SET(conn, 'MATERIALIZED VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{{ SECLABEL.SET(conn, 'MATERIALIZED VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.SET(conn, 'MATERIALIZED VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{{ SECLABEL.SET(conn, 'MATERIALIZED VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{# ===== Grant Permissions to User Role on Views/Tables ==== #}
|
||||
{% import 'macros/schemas/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{# We will generate Security Label SQL using macro #}
|
||||
{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABLE.SET(conn, 'MATERIALIZED VIEW', data.name, r.provider, r.label, data.schema) }}{% endfor %}{% endif %}
|
||||
{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABEL.SET(conn, 'MATERIALIZED VIEW', data.name, r.provider, r.label, data.schema) }}{% endfor %}{% endif %}
|
||||
{% if data.datacl %}{% for priv in data.datacl %}{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }}{% endfor %}{% endif %}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{# ===================== Update View ===================#}
|
||||
{% import 'macros/schemas/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{%- if data -%}
|
||||
{% set view_name = data.name if data.name else o_data.name %}
|
||||
@@ -197,17 +197,17 @@ COMMENT ON MATERIALIZED VIEW {{ conn|qtIdent(view_schema, view_name) }}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.UNSET(conn, 'MATERIALIZED VIEW', data.name, r.provider, data.schema) }}
|
||||
{{ SECLABEL.UNSET(conn, 'MATERIALIZED VIEW', data.name, r.provider, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.SET(conn, 'MATERIALIZED VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{{ SECLABEL.SET(conn, 'MATERIALIZED VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.SET(conn, 'MATERIALIZED VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{{ SECLABEL.SET(conn, 'MATERIALIZED VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{# ===== Grant Permissions to User Role on Views/Tables ===== #}
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{# ===== We will generate Security Label SQL using macro ===== #}
|
||||
{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABLE.APPLY(conn, 'VIEW', data.name, r.provider, r.label) }}{{'\r'}}{% endfor %}{{'\r'}}{% endif %}{% if data.datacl %}
|
||||
{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}{{'\r'}}{% endfor %}{{'\r'}}{% endif %}{% if data.datacl %}
|
||||
{% for priv in data.datacl %}{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }}{% endfor %}{% endif %}
|
||||
|
||||
@@ -15,18 +15,12 @@ SELECT
|
||||
CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view,
|
||||
{% endif %}
|
||||
(SELECT
|
||||
array_agg(label)
|
||||
array_agg(provider || '=' || label)
|
||||
FROM
|
||||
pg_seclabels sl1
|
||||
WHERE
|
||||
sl1.objoid=c.oid AND sl1.objsubid=0
|
||||
) AS labels,
|
||||
(SELECT
|
||||
array_agg(provider)
|
||||
FROM
|
||||
pg_seclabels sl2
|
||||
WHERE sl2.objoid=c.oid AND sl2.objsubid=0
|
||||
) AS providers
|
||||
) AS seclabels,
|
||||
FROM pg_class c
|
||||
LEFT OUTER JOIN pg_namespace nsp on nsp.oid = c.relnamespace
|
||||
LEFT OUTER JOIN pg_tablespace spc on spc.oid=c.reltablespace
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{# ============================ Update View ========================= #}
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{% if data %}
|
||||
{% set view_name = data.name if data.name else o_data.name %}
|
||||
@@ -50,17 +50,17 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.DROP(conn, 'VIEW', data.name, r.provider) }}
|
||||
{{ SECLABEL.UNSET(conn, 'VIEW', data.name, r.provider, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.APPLY(conn, 'VIEW', data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.APPLY(conn, 'VIEW', data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{# ===== Grant Permissions to User Role on Views/Tables ===== #}
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{# ===== We will generate Security Label SQL using macro ===== #}
|
||||
{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABLE.APPLY(conn, 'VIEW', data.name, r.provider, r.label) }}{{'\r'}}{% endfor %}{{'\r'}}{% endif %}{% if data.datacl %}
|
||||
{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}{{'\r'}}{% endfor %}{{'\r'}}{% endif %}{% if data.datacl %}
|
||||
{% for priv in data.datacl %}{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }}{% endfor %}{% endif %}
|
||||
|
||||
@@ -15,18 +15,13 @@ SELECT
|
||||
{% if vid and datlastsysoid %}
|
||||
CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view,
|
||||
{% endif %}
|
||||
(SELECT
|
||||
array_agg(label)
|
||||
FROM
|
||||
pg_seclabels sl1
|
||||
WHERE
|
||||
sl1.objoid=c.oid AND sl1.objsubid=0) AS labels,
|
||||
(SELECT
|
||||
array_agg(provider)
|
||||
FROM
|
||||
pg_seclabels sl2
|
||||
WHERE
|
||||
sl2.objoid=c.oid AND sl2.objsubid=0) AS providers,
|
||||
(SELECT
|
||||
array_agg(provider || '=' || label)
|
||||
FROM
|
||||
pg_seclabels sl1
|
||||
WHERE
|
||||
sl1.objoid=c.oid AND sl1.objsubid=0
|
||||
) AS seclabels,
|
||||
(substring(array_to_string(c.reloptions, ',')
|
||||
FROM 'security_barrier=([a-z|0-9]*)'))::boolean AS security_barrier
|
||||
FROM pg_class c
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{# ============================ Update View ========================= #}
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{% if data %}
|
||||
{% set view_name = data.name if data.name else o_data.name %}
|
||||
@@ -58,17 +58,17 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.DROP(conn, 'VIEW', data.name, r.provider) }}
|
||||
{{ SECLABEL.UNSET(conn, 'VIEW', data.name, r.provider, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.APPLY(conn, 'VIEW', data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.APPLY(conn, 'VIEW', data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{# ===== Grant Permissions to User Role on Views/Tables ===== #}
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{# ===== We will generate Security Label SQL using macro ===== #}
|
||||
{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABLE.APPLY(conn, 'VIEW', data.name, r.provider, r.label) }}{{'\r'}}{% endfor %}{{'\r'}}{% endif %}{% if data.datacl %}
|
||||
{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}{{'\r'}}{% endfor %}{{'\r'}}{% endif %}{% if data.datacl %}
|
||||
{% for priv in data.datacl %}{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }}{% endfor %}{% endif %}
|
||||
|
||||
@@ -16,18 +16,13 @@ SELECT
|
||||
{% if vid and datlastsysoid %}
|
||||
CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view,
|
||||
{% endif %}
|
||||
(SELECT
|
||||
array_agg(label)
|
||||
FROM
|
||||
pg_seclabels sl1
|
||||
WHERE
|
||||
sl1.objoid=c.oid AND sl1.objsubid=0) AS labels,
|
||||
(SELECT
|
||||
array_agg(provider)
|
||||
FROM
|
||||
pg_seclabels sl2
|
||||
WHERE
|
||||
sl2.objoid=c.oid AND sl2.objsubid=0) AS providers,
|
||||
(SELECT
|
||||
array_agg(provider || '=' || label)
|
||||
FROM
|
||||
pg_seclabels sl1
|
||||
WHERE
|
||||
sl1.objoid=c.oid AND sl1.objsubid=0
|
||||
) AS seclabels,
|
||||
(substring(array_to_string(c.reloptions, ',')
|
||||
FROM 'security_barrier=([a-z|0-9]*)'))::boolean AS security_barrier
|
||||
FROM pg_class c
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{# ============================ Update View ========================= #}
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{% if data %}
|
||||
{% set view_name = data.name if data.name else o_data.name %}
|
||||
@@ -58,17 +58,17 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.DROP(conn, 'VIEW', data.name, r.provider) }}
|
||||
{{ SECLABEL.UNSET(conn, 'VIEW', data.name, r.provider, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.APPLY(conn, 'VIEW', data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.APPLY(conn, 'VIEW', data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{# ===== Grant Permissions to User Role on Views/Tables ===== #}
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{# ===== We will generate Security Label SQL using macro ===== #}
|
||||
{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABLE.APPLY(conn, 'VIEW', data.name, r.provider, r.label) }}{{'\r'}}{% endfor %}{{'\r'}}{% endif %}{% if data.datacl %}
|
||||
{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}{{'\r'}}{% endfor %}{{'\r'}}{% endif %}{% if data.datacl %}
|
||||
{% for priv in data.datacl %}{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }}{% endfor %}{% endif %}
|
||||
|
||||
@@ -17,18 +17,13 @@ SELECT
|
||||
{% if vid and datlastsysoid %}
|
||||
CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view,
|
||||
{% endif %}
|
||||
(SELECT
|
||||
array_agg(label)
|
||||
FROM
|
||||
pg_seclabels sl1
|
||||
WHERE
|
||||
sl1.objoid=c.oid AND sl1.objsubid=0) AS labels,
|
||||
(SELECT
|
||||
array_agg(provider)
|
||||
FROM
|
||||
pg_seclabels sl2
|
||||
WHERE
|
||||
sl2.objoid=c.oid AND sl2.objsubid=0) AS providers,
|
||||
(SELECT
|
||||
array_agg(provider || '=' || label)
|
||||
FROM
|
||||
pg_seclabels sl1
|
||||
WHERE
|
||||
sl1.objoid=c.oid AND sl1.objsubid=0
|
||||
) AS seclabels,
|
||||
substring(array_to_string(c.reloptions, ',')
|
||||
FROM 'check_option=([a-z]*)') AS check_option,
|
||||
(substring(array_to_string(c.reloptions, ',')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{# ============================ Update View ========================= #}
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{% if data %}
|
||||
{% set view_name = data.name if data.name else o_data.name %}
|
||||
@@ -64,17 +64,17 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.DROP(conn, 'VIEW', data.name, r.provider) }}
|
||||
{{ SECLABEL.UNSET(conn, 'VIEW', data.name, r.provider, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.APPLY(conn, 'VIEW', data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.APPLY(conn, 'VIEW', data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{# ===== Grant Permissions to User Role on Views/Tables ===== #}
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{# ===== We will generate Security Label SQL using macro ===== #}
|
||||
{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABLE.APPLY(conn, 'VIEW', data.name, r.provider, r.label) }}{{'\r'}}{% endfor %}{{'\r'}}{% endif %}{% if data.datacl %}
|
||||
{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}{{'\r'}}{% endfor %}{{'\r'}}{% endif %}{% if data.datacl %}
|
||||
{% for priv in data.datacl %}{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }}{% endfor %}{% endif %}
|
||||
|
||||
@@ -16,18 +16,13 @@ SELECT
|
||||
{% if vid and datlastsysoid %}
|
||||
CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view,
|
||||
{% endif %}
|
||||
(SELECT
|
||||
array_agg(label)
|
||||
FROM
|
||||
pg_seclabels sl1
|
||||
WHERE
|
||||
sl1.objoid=c.oid AND sl1.objsubid=0) AS labels,
|
||||
(SELECT
|
||||
array_agg(provider)
|
||||
FROM
|
||||
pg_seclabels sl2
|
||||
WHERE
|
||||
sl2.objoid=c.oid AND sl2.objsubid=0) AS providers,
|
||||
(SELECT
|
||||
array_agg(provider || '=' || label)
|
||||
FROM
|
||||
pg_seclabels sl1
|
||||
WHERE
|
||||
sl1.objoid=c.oid AND sl1.objsubid=0
|
||||
) AS seclabels,
|
||||
substring(array_to_string(c.reloptions, ',')
|
||||
FROM 'check_option=([a-z]*)') AS check_option,
|
||||
(substring(array_to_string(c.reloptions, ',')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{# ============================ Update View ========================= #}
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{% if data %}
|
||||
{% set view_name = data.name if data.name else o_data.name %}
|
||||
@@ -58,17 +58,17 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.DROP(conn, 'VIEW', data.name, r.provider) }}
|
||||
{{ SECLABEL.UNSET(conn, 'VIEW', data.name, r.provider, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.APPLY(conn, 'VIEW', data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.APPLY(conn, 'VIEW', data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{# ===== Grant Permissions to User Role on Views/Tables ===== #}
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{# ===== We will generate Security Label SQL using macro ===== #}
|
||||
{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABLE.APPLY(conn, 'VIEW', data.name, r.provider, r.label) }}{{'\r'}}{% endfor %}{{'\r'}}{% endif %}{% if data.datacl %}
|
||||
{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}{{'\r'}}{% endfor %}{{'\r'}}{% endif %}{% if data.datacl %}
|
||||
{% for priv in data.datacl %}{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }}{% endfor %}{% endif %}
|
||||
|
||||
@@ -14,18 +14,13 @@ SELECT
|
||||
{% if vid and datlastsysoid %}
|
||||
CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view,
|
||||
{% endif %}
|
||||
(SELECT
|
||||
array_agg(label)
|
||||
FROM
|
||||
pg_seclabels sl1
|
||||
WHERE
|
||||
sl1.objoid=c.oid AND sl1.objsubid=0) AS labels,
|
||||
(SELECT
|
||||
array_agg(provider)
|
||||
FROM
|
||||
pg_seclabels sl2
|
||||
WHERE
|
||||
sl2.objoid=c.oid AND sl2.objsubid=0) AS providers,
|
||||
(SELECT
|
||||
array_agg(provider || '=' || label)
|
||||
FROM
|
||||
pg_seclabels sl1
|
||||
WHERE
|
||||
sl1.objoid=c.oid AND sl1.objsubid=0
|
||||
) AS seclabels,
|
||||
(substring(array_to_string(c.reloptions, ',')
|
||||
FROM 'security_barrier=([a-z|0-9]*)'))::boolean AS security_barrier
|
||||
FROM pg_class c
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{# ============================ Update View ========================= #}
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{% if data %}
|
||||
{% set view_name = data.name if data.name else o_data.name %}
|
||||
@@ -58,17 +58,17 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.DROP(conn, 'VIEW', data.name, r.provider) }}
|
||||
{{ SECLABEL.UNSET(conn, 'VIEW', data.name, r.provider, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.APPLY(conn, 'VIEW', data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.APPLY(conn, 'VIEW', data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{# ===== Grant Permissions to User Role on Views/Tables ===== #}
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{# ===== We will generate Security Label SQL using macro ===== #}
|
||||
{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABLE.APPLY(conn, 'VIEW', data.name, r.provider, r.label) }}{{'\r'}}{% endfor %}{{'\r'}}{% endif %}{% if data.datacl %}
|
||||
{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}{{'\r'}}{% endfor %}{{'\r'}}{% endif %}{% if data.datacl %}
|
||||
{% for priv in data.datacl %}{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }}{% endfor %}{% endif %}
|
||||
|
||||
@@ -16,18 +16,13 @@ SELECT
|
||||
{% if vid and datlastsysoid %}
|
||||
CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view,
|
||||
{% endif %}
|
||||
(SELECT
|
||||
array_agg(label)
|
||||
FROM
|
||||
pg_seclabels sl1
|
||||
WHERE
|
||||
sl1.objoid=c.oid AND sl1.objsubid=0) AS labels,
|
||||
(SELECT
|
||||
array_agg(provider)
|
||||
FROM
|
||||
pg_seclabels sl2
|
||||
WHERE
|
||||
sl2.objoid=c.oid AND sl2.objsubid=0) AS providers,
|
||||
(SELECT
|
||||
array_agg(provider || '=' || label)
|
||||
FROM
|
||||
pg_seclabels sl1
|
||||
WHERE
|
||||
sl1.objoid=c.oid AND sl1.objsubid=0
|
||||
) AS seclabels,
|
||||
(substring(array_to_string(c.reloptions, ',')
|
||||
FROM 'security_barrier=([a-z|0-9]*)'))::boolean AS security_barrier
|
||||
FROM pg_class c
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{# ============================ Update View ========================= #}
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{% if data %}
|
||||
{% set view_name = data.name if data.name else o_data.name %}
|
||||
@@ -58,17 +58,17 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.DROP(conn, 'VIEW', data.name, r.provider) }}
|
||||
{{ SECLABEL.UNSET(conn, 'VIEW', data.name, r.provider, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.APPLY(conn, 'VIEW', data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.APPLY(conn, 'VIEW', data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{# ===== Grant Permissions to User Role on Views/Tables ===== #}
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{# ===== We will generate Security Label SQL using macro ===== #}
|
||||
{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABLE.APPLY(conn, 'VIEW', data.name, r.provider, r.label) }}{{'\r'}}{% endfor %}{{'\r'}}{% endif %}{% if data.datacl %}
|
||||
{% if data.seclabels %}{% for r in data.seclabels %}{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}{{'\r'}}{% endfor %}{{'\r'}}{% endif %}{% if data.datacl %}
|
||||
{% for priv in data.datacl %}{{ PRIVILEGE.SET(conn, 'TABLE', priv.grantee, data.name, priv.without_grant, priv.with_grant, data.schema) }}{% endfor %}{% endif %}
|
||||
|
||||
@@ -17,18 +17,13 @@ SELECT
|
||||
{% if vid and datlastsysoid %}
|
||||
CASE WHEN {{vid}} <= {{datlastsysoid}} THEN True ELSE False END AS system_view,
|
||||
{% endif %}
|
||||
(SELECT
|
||||
array_agg(label)
|
||||
FROM
|
||||
pg_seclabels sl1
|
||||
WHERE
|
||||
sl1.objoid=c.oid AND sl1.objsubid=0) AS labels,
|
||||
(SELECT
|
||||
array_agg(provider)
|
||||
FROM
|
||||
pg_seclabels sl2
|
||||
WHERE
|
||||
sl2.objoid=c.oid AND sl2.objsubid=0) AS providers,
|
||||
(SELECT
|
||||
array_agg(provider || '=' || label)
|
||||
FROM
|
||||
pg_seclabels sl1
|
||||
WHERE
|
||||
sl1.objoid=c.oid AND sl1.objsubid=0
|
||||
) AS seclabels,
|
||||
substring(array_to_string(c.reloptions, ',')
|
||||
FROM 'check_option=([a-z]*)') AS check_option,
|
||||
(substring(array_to_string(c.reloptions, ',')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{# ============================ Update View ========================= #}
|
||||
{% import 'macros/security.macros' as SECLABLE %}
|
||||
{% import 'macros/schemas/security.macros' as SECLABEL %}
|
||||
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||
{% if data %}
|
||||
{% set view_name = data.name if data.name else o_data.name %}
|
||||
@@ -64,17 +64,17 @@ COMMENT ON VIEW {{ conn|qtIdent(view_schema, view_name) }}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABLE.DROP(conn, 'VIEW', data.name, r.provider) }}
|
||||
{{ SECLABEL.UNSET(conn, 'VIEW', data.name, r.provider, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABLE.APPLY(conn, 'VIEW', data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABLE.APPLY(conn, 'VIEW', data.name, r.provider, r.label) }}
|
||||
{{ SECLABEL.SET(conn, 'VIEW', data.name, r.provider, r.label, data.schema) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -289,7 +289,7 @@ function($, _, S, pgAdmin, pgBrowser, Alertify) {
|
||||
canAdd: true, canEdit: false, canDelete: true, hasRole: true,
|
||||
control: Backform.VariableCollectionControl, node: 'role'
|
||||
},{
|
||||
id: 'securities', label: '{{ _('Security Labels') }}',
|
||||
id: 'seclabels', label: '{{ _('Security Labels') }}',
|
||||
model: pgBrowser.SecLabelModel,
|
||||
editable: false, type: 'collection', canEdit: false,
|
||||
group: '{{ _('Security') }}', canDelete: true,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{% import 'macros/security.macros' as SECLABEL %}
|
||||
{% import 'macros/variable.macros' as VARIABLE %}
|
||||
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %}
|
||||
@@ -128,3 +129,22 @@ ALTER DATABASE {{ conn|qtIdent(data.name) }} WITH CONNECTION LIMIT = {{ data.dat
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
{# Change the security labels #}
|
||||
{% if data.seclabels and data.seclabels|length > 0 %}
|
||||
{% set seclabels = data.seclabels %}
|
||||
{% if 'deleted' in seclabels and seclabels.deleted|length > 0 %}
|
||||
{% for r in seclabels.deleted %}
|
||||
{{ SECLABEL.DROP(conn, 'DATABASE', data.name, r.provider) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'added' in seclabels and seclabels.added|length > 0 %}
|
||||
{% for r in seclabels.added %}
|
||||
{{ SECLABEL.APPLY(conn, 'DATABASE', data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if 'changed' in seclabels and seclabels.changed|length > 0 %}
|
||||
{% for r in seclabels.changed %}
|
||||
{{ SECLABEL.APPLY(conn, 'DATABASE', data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
# other sql statments along with it, so we wrote
|
||||
# seprate sql for rest alter sql statments here
|
||||
#}
|
||||
{% import 'macros/security.macros' as SECLABEL %}
|
||||
{% import 'macros/variable.macros' as VARIABLE %}
|
||||
{% import 'macros/privilege.macros' as PRIVILEGE %}
|
||||
{% import 'macros/default_privilege.macros' as DEFAULT_PRIVILEGE %}
|
||||
@@ -11,6 +12,12 @@ COMMENT ON DATABASE {{ conn|qtIdent(data.name) }}
|
||||
IS {{ data.comments|qtLiteral }};
|
||||
{% endif %}
|
||||
|
||||
{# Generate the security labels #}
|
||||
{% if data.seclabels %}
|
||||
{% for r in data.seclabels %}
|
||||
{{ SECLABEL.APPLY(conn, 'DATABASE', data.name, r.provider, r.label) }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{# TO generate Variable SQL using macro #}
|
||||
{% if data.variables %}
|
||||
{% for var in data.variables %}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user