diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py index b1052491c..14fdef132 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/__init__.py @@ -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" diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/js/event_trigger.js b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/js/event_trigger.js index 195a292da..af1f6e391 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/js/event_trigger.js +++ b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/js/event_trigger.js @@ -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. diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/grant.sql index f8365ff26..7c92eede9 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/grant.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/grant.sql @@ -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) }} diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/properties.sql index 0df12b3d2..d0a100907 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/update.sql index 34d9846bb..8891a5587 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/event_triggers/templates/event_triggers/sql/9.3_plus/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/languages/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/languages/__init__.py index e1c31c430..04e87a11c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/languages/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/languages/__init__.py @@ -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): diff --git a/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.1_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.1_plus/properties.sql index 96884d4c2..530664272 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.1_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.1_plus/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.1_plus/sqlpane.sql b/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.1_plus/sqlpane.sql index f6978ba2a..d0003cf42 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.1_plus/sqlpane.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.1_plus/sqlpane.sql @@ -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 %} \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.1_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.1_plus/update.sql index 802ad833d..526cd9d54 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.1_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.1_plus/update.sql @@ -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 %} \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.3_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.3_plus/properties.sql index 96884d4c2..530664272 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.3_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.3_plus/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.3_plus/sqlpane.sql b/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.3_plus/sqlpane.sql index 905ef1a96..d4f4f65d1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.3_plus/sqlpane.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.3_plus/sqlpane.sql @@ -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 %} \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.3_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.3_plus/update.sql index 802ad833d..526cd9d54 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.3_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/languages/templates/languages/sql/9.3_plus/update.sql @@ -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 %} \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.1_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.1_plus/create.sql index a02e0e67f..e0cfe9a42 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.1_plus/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.1_plus/create.sql @@ -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 -%} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.1_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.1_plus/update.sql index 1cab193da..9cbe6248d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.1_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.1_plus/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/create.sql index b5b83bf72..554d081de 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/create.sql @@ -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 -%} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/properties.sql index 289298895..87cc84cd1 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/update.sql index 83c280fe9..7b8550f5f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/domains/templates/domains/sql/9.2_plus/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.1_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.1_plus/create.sql index df018cb7a..a1a8743ce 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.1_plus/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.1_plus/create.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.1_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.1_plus/update.sql index 913d4fb70..0556b1e61 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.1_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.1_plus/update.sql @@ -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%} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/create.sql index 139cc8fc5..cbffa8926 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/create.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/properties.sql index c557c87a6..b2ef81d3a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/update.sql index 078cea656..8b85b9064 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.2_plus/update.sql @@ -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%} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/create.sql index 5e1d4e39f..093eec02e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/create.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/properties.sql index 3976a075f..586c42aa2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/properties.sql @@ -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 %}, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/update.sql index 1f3d50707..3fc81de1e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/foreign_tables/templates/foreign_tables/sql/9.5_plus/update.sql @@ -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%} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/js/functions.js b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/js/functions.js index 7e4ffa7fb..2ef91f896 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/js/functions.js +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/js/functions.js @@ -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() diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/create.sql index dde07cda2..6976a75b5 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/create.sql @@ -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 -%} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/properties.sql index ff7829808..9e8a8baaa 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.2_plus/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/properties.sql index ff7829808..9e8a8baaa 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/pg/sql/9.5_plus/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/ppas/sql/9.2_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/ppas/sql/9.2_plus/properties.sql index ff7829808..9e8a8baaa 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/ppas/sql/9.2_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/ppas/sql/9.2_plus/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/ppas/sql/9.5_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/ppas/sql/9.5_plus/properties.sql index ff7829808..9e8a8baaa 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/ppas/sql/9.5_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/function/ppas/sql/9.5_plus/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedure/ppas/sql/9.2_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedure/ppas/sql/9.2_plus/properties.sql index 6cfec94aa..9492f3c3d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedure/ppas/sql/9.2_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedure/ppas/sql/9.2_plus/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedure/ppas/sql/9.5_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedure/ppas/sql/9.5_plus/properties.sql index 6cfec94aa..9492f3c3d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedure/ppas/sql/9.5_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedure/ppas/sql/9.5_plus/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_function/pg/sql/9.2_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_function/pg/sql/9.2_plus/create.sql index ddf6e25fd..149c2049e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_function/pg/sql/9.2_plus/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_function/pg/sql/9.2_plus/create.sql @@ -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 -%} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_function/pg/sql/9.2_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_function/pg/sql/9.2_plus/properties.sql index 946887125..409e0ae28 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_function/pg/sql/9.2_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_function/pg/sql/9.2_plus/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_function/pg/sql/9.5_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_function/pg/sql/9.5_plus/properties.sql index 946887125..409e0ae28 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_function/pg/sql/9.5_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_function/pg/sql/9.5_plus/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_function/ppas/sql/9.2_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_function/ppas/sql/9.2_plus/properties.sql index 946887125..409e0ae28 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_function/ppas/sql/9.2_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_function/ppas/sql/9.2_plus/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_function/ppas/sql/9.5_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_function/ppas/sql/9.5_plus/properties.sql index 946887125..409e0ae28 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_function/ppas/sql/9.5_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_function/ppas/sql/9.5_plus/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py index b5025a06e..1aa5ae0f0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/__init__.py @@ -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: diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequence/sql/9.1_plus/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequence/sql/9.1_plus/grant.sql index fd6a3fbaf..d4a382c66 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequence/sql/9.1_plus/grant.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequence/sql/9.1_plus/grant.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequence/sql/9.1_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequence/sql/9.1_plus/update.sql index 59167699f..cb1df060c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequence/sql/9.1_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/sequences/templates/sequence/sql/9.1_plus/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.1_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.1_plus/create.sql index 51eea522b..5f04b6e52 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.1_plus/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.1_plus/create.sql @@ -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 %} \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.1_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.1_plus/properties.sql index d53690637..130b4a827 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.1_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.1_plus/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.1_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.1_plus/update.sql index 9501a18a2..7b26dd705 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.1_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.1_plus/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/create.sql index 51eea522b..5f04b6e52 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/create.sql @@ -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 %} \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/properties.sql index d53690637..8c5b18935 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/update.sql index 39e2f3117..4d6a9fe6e 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/sql/9.2_plus/update.sql @@ -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 %} \ No newline at end of file diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/create.sql index c0fb5e449..71ac1c69d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/create.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/update.sql index 8c64dada3..fa22b89bf 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.1_plus/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/create.sql index c0fb5e449..71ac1c69d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/create.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/update.sql index 8c64dada3..fa22b89bf 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/table/sql/9.5_plus/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/9.1_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/9.1_plus/sql/update.sql index 13eb2e85c..39f7f94c7 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/9.1_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/9.1_plus/sql/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/9.2_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/9.2_plus/sql/update.sql index 13eb2e85c..39f7f94c7 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/9.2_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/pg/9.2_plus/sql/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/9.1_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/9.1_plus/sql/properties.sql index 245d45f8c..41ee062e9 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/9.1_plus/sql/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/9.1_plus/sql/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/9.1_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/9.1_plus/sql/update.sql index 13eb2e85c..39f7f94c7 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/9.1_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/9.1_plus/sql/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/9.2_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/9.2_plus/sql/properties.sql index abd48908e..6dc81555b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/9.2_plus/sql/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/9.2_plus/sql/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/9.2_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/9.2_plus/sql/update.sql index 13eb2e85c..39f7f94c7 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/9.2_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/catalog/ppas/9.2_plus/sql/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/pg/9.1_plus/sql/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/pg/9.1_plus/sql/create.sql index 6e6a81857..4a071c4b9 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/pg/9.1_plus/sql/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/pg/9.1_plus/sql/create.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/pg/9.1_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/pg/9.1_plus/sql/properties.sql index c4940bd7e..8c9d47a1f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/pg/9.1_plus/sql/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/pg/9.1_plus/sql/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/pg/9.2_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/pg/9.2_plus/sql/properties.sql index 0d7b3392b..e46a630b2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/pg/9.2_plus/sql/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/pg/9.2_plus/sql/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/ppas/9.1_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/ppas/9.1_plus/sql/update.sql index a0bb533f0..9f0a849c5 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/ppas/9.1_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/ppas/9.1_plus/sql/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/ppas/9.2_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/ppas/9.2_plus/sql/update.sql index acfb80918..a324937bb 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/ppas/9.2_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/schema/ppas/9.2_plus/sql/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py index 769ebb22b..381232d7c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/__init__.py @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/sql/9.1_plus/create.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/sql/9.1_plus/create.sql index 8284a64ca..53bd9f69a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/sql/9.1_plus/create.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/sql/9.1_plus/create.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/sql/9.1_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/sql/9.1_plus/properties.sql index de261a5ce..83c6a6a9d 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/sql/9.1_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/sql/9.1_plus/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/sql/9.1_plus/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/sql/9.1_plus/update.sql index 23ffad29d..3af2ea1f6 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/sql/9.1_plus/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/types/templates/type/sql/9.1_plus/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py index 741423fab..eef478b1c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/__init__.py @@ -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( diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.3_plus/sql/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.3_plus/sql/grant.sql index be6e6de8c..c8228cb89 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.3_plus/sql/grant.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.3_plus/sql/grant.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.3_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.3_plus/sql/update.sql index 1cc0db70f..ee1966060 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.3_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.3_plus/sql/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.4_plus/sql/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.4_plus/sql/grant.sql index be6e6de8c..c8228cb89 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.4_plus/sql/grant.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.4_plus/sql/grant.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.4_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.4_plus/sql/update.sql index 1cc0db70f..ee1966060 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.4_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/pg/9.4_plus/sql/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/ppas/9.3_plus/sql/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/ppas/9.3_plus/sql/grant.sql index be6e6de8c..c8228cb89 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/ppas/9.3_plus/sql/grant.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/ppas/9.3_plus/sql/grant.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/ppas/9.3_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/ppas/9.3_plus/sql/update.sql index 1cc0db70f..ee1966060 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/ppas/9.3_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mview/ppas/9.3_plus/sql/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.1_plus/sql/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.1_plus/sql/grant.sql index 35a5e25f9..a7e1585bd 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.1_plus/sql/grant.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.1_plus/sql/grant.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.1_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.1_plus/sql/properties.sql index ce1d80185..03aa2e6e0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.1_plus/sql/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.1_plus/sql/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.1_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.1_plus/sql/update.sql index 16a11e8d8..291b7760a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.1_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.1_plus/sql/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.2_plus/sql/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.2_plus/sql/grant.sql index 35a5e25f9..a7e1585bd 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.2_plus/sql/grant.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.2_plus/sql/grant.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.2_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.2_plus/sql/properties.sql index a36de2613..8ad3b3644 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.2_plus/sql/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.2_plus/sql/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.2_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.2_plus/sql/update.sql index b008ede54..38606cc0b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.2_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.2_plus/sql/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.3_plus/sql/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.3_plus/sql/grant.sql index 35a5e25f9..a7e1585bd 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.3_plus/sql/grant.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.3_plus/sql/grant.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.3_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.3_plus/sql/properties.sql index 0fc7a2f6c..045cc9a3c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.3_plus/sql/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.3_plus/sql/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.3_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.3_plus/sql/update.sql index b008ede54..38606cc0b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.3_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.3_plus/sql/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.4_plus/sql/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.4_plus/sql/grant.sql index 35a5e25f9..a7e1585bd 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.4_plus/sql/grant.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.4_plus/sql/grant.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.4_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.4_plus/sql/properties.sql index 4e5a88912..6dea869f7 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.4_plus/sql/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.4_plus/sql/properties.sql @@ -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, ',') diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.4_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.4_plus/sql/update.sql index 78b655e06..647711cda 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.4_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/pg/9.4_plus/sql/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.1_plus/sql/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.1_plus/sql/grant.sql index 35a5e25f9..a7e1585bd 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.1_plus/sql/grant.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.1_plus/sql/grant.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.1_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.1_plus/sql/properties.sql index aa270e25b..da9053c16 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.1_plus/sql/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.1_plus/sql/properties.sql @@ -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, ',') diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.1_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.1_plus/sql/update.sql index b008ede54..38606cc0b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.1_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.1_plus/sql/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.2_plus/sql/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.2_plus/sql/grant.sql index 35a5e25f9..a7e1585bd 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.2_plus/sql/grant.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.2_plus/sql/grant.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.2_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.2_plus/sql/properties.sql index 20eb3df41..43d53e7df 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.2_plus/sql/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.2_plus/sql/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.2_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.2_plus/sql/update.sql index b008ede54..38606cc0b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.2_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.2_plus/sql/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.3_plus/sql/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.3_plus/sql/grant.sql index 35a5e25f9..a7e1585bd 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.3_plus/sql/grant.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.3_plus/sql/grant.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.3_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.3_plus/sql/properties.sql index 0fc7a2f6c..045cc9a3c 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.3_plus/sql/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.3_plus/sql/properties.sql @@ -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 diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.3_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.3_plus/sql/update.sql index b008ede54..38606cc0b 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.3_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.3_plus/sql/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.4_plus/sql/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.4_plus/sql/grant.sql index 35a5e25f9..a7e1585bd 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.4_plus/sql/grant.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.4_plus/sql/grant.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.4_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.4_plus/sql/properties.sql index 4e5a88912..6dea869f7 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.4_plus/sql/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.4_plus/sql/properties.sql @@ -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, ',') diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.4_plus/sql/update.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.4_plus/sql/update.sql index 78b655e06..647711cda 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.4_plus/sql/update.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/view/ppas/9.4_plus/sql/update.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js index f2a49c9c1..5d74661dc 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js +++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/js/databases.js @@ -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, diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/alter_online.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/alter_online.sql index ff32925bf..e69c9b512 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/alter_online.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/alter_online.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/grant.sql index 4572cc944..b9275c6e0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/grant.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.1_plus/grant.sql @@ -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 %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/grant.sql index 2884956c2..94f2bf404 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/grant.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.2_plus/grant.sql @@ -13,8 +13,8 @@ COMMENT ON DATABASE {{ conn|qtIdent(data.name) }} {% endif %} {# Generate the security labels #} -{% if data.securities %} -{% for r in data.securities %} +{% if data.seclabels %} +{% for r in data.seclabels %} {{ SECLABEL.APPLY(conn, 'DATABASE', data.name, r.provider, r.label) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/grant.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/grant.sql index 3731a55c7..6aa4af668 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/grant.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/9.3_plus/grant.sql @@ -13,8 +13,8 @@ COMMENT ON DATABASE {{ conn|qtIdent(data.name) }} {% endif %} {# Change the security labels #} -{% if data.securities %} -{% for r in data.securities %} +{% if data.seclabels %} +{% for r in data.seclabels %} {{ SECLABEL.APPLY(conn, 'DATABASE', data.name, r.provider, r.label) }} {% endfor %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/databases/utils.py b/web/pgadmin/browser/server_groups/servers/databases/utils.py index 1048489df..534bd176a 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/utils.py +++ b/web/pgadmin/browser/server_groups/servers/databases/utils.py @@ -26,6 +26,7 @@ def parse_sec_labels_from_db(db_sec_labels): if db_sec_labels is not None: for sec in db_sec_labels: + import re sec = re.search(r'([^=]+)=(.*$)', sec) sec_lbls.append({ 'provider': sec.group(1), diff --git a/web/pgadmin/browser/server_groups/servers/roles/__init__.py b/web/pgadmin/browser/server_groups/servers/roles/__init__.py index ddb55b9dd..4e0379a76 100644 --- a/web/pgadmin/browser/server_groups/servers/roles/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/roles/__init__.py @@ -653,6 +653,7 @@ rolmembership:{ 'provider': sec.group(1), 'label': sec.group(2) }) + row['seclabels'] = res @check_precondition(action='properties') def properties(self, gid, sid, rid): diff --git a/web/pgadmin/browser/server_groups/servers/roles/templates/role/sql/post9_1/update.sql b/web/pgadmin/browser/server_groups/servers/roles/templates/role/sql/post9_1/update.sql index dd79100b1..ae5bef615 100644 --- a/web/pgadmin/browser/server_groups/servers/roles/templates/role/sql/post9_1/update.sql +++ b/web/pgadmin/browser/server_groups/servers/roles/templates/role/sql/post9_1/update.sql @@ -90,19 +90,19 @@ GRANT {{ conn|qtIdent(data.members)|join(', ') }} TO {{ conn|qtIdent(rolname) }} {% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} {% for r in seclabels.deleted %} -{{ SECLABEL.DROP(conn, 'ROLE', data.rolname, r.provider) }} +{{ SECLABEL.DROP(conn, 'ROLE', rolname, r.provider) }} {% endfor %} {% endif %} {% if 'added' in seclabels and seclabels.added|length > 0 %} {% for r in seclabels.added %} -{{ SECLABEL.APPLY(conn, 'ROLE', data.rolname, r.provider, r.label) }} +{{ SECLABEL.APPLY(conn, 'ROLE', rolname, r.provider, r.label) }} {% endfor %} {% endif %} {% if 'changed' in seclabels and seclabels.changed|length > 0 %} {% for r in seclabels.changed %} -{{ SECLABEL.APPLY(conn, 'ROLE', data.rolname, r.provider, r.label) }} +{{ SECLABEL.APPLY(conn, 'ROLE', rolname, r.provider, r.label) }} {% endfor %} {% endif %} {% endif %} diff --git a/web/pgadmin/browser/server_groups/servers/roles/templates/role/sql/post9_4/update.sql b/web/pgadmin/browser/server_groups/servers/roles/templates/role/sql/post9_4/update.sql index 2f7574f6a..2c4a70f36 100644 --- a/web/pgadmin/browser/server_groups/servers/roles/templates/role/sql/post9_4/update.sql +++ b/web/pgadmin/browser/server_groups/servers/roles/templates/role/sql/post9_4/update.sql @@ -65,19 +65,19 @@ GRANT {{ conn|qtIdent(data.members)|join(', ') }} TO {{ conn|qtIdent(rolname) }} {% if 'deleted' in seclabels and seclabels.deleted|length > 0 %} {% for r in seclabels.deleted %} -{{ SECLABEL.DROP(conn, 'ROLE', data.rolname, r.provider) }} +{{ SECLABEL.DROP(conn, 'ROLE', rolname, r.provider) }} {% endfor %} {% endif %} {% if 'added' in seclabels and seclabels.added|length > 0 %} {% for r in seclabels.added %} -{{ SECLABEL.APPLY(conn, 'ROLE', data.rolname, r.provider, r.label) }} +{{ SECLABEL.APPLY(conn, 'ROLE', rolname, r.provider, r.label) }} {% endfor %} {% endif %} {% if 'changed' in seclabels and seclabels.changed|length > 0 %} {% for r in seclabels.changed %} -{{ SECLABEL.APPLY(conn, 'ROLE', data.rolname, r.provider, r.label) }} +{{ SECLABEL.APPLY(conn, 'ROLE', rolname, r.provider, r.label) }} {% endfor %} {% endif %} {% endif %}