Security Label and ACL template macros:

Way to use in template:

1) Security labels:

SECLABLE.SET(conn, object_type, object_name, provider, security_label,
object.schema)

SECLABLE.UNSET(conn, object_type, object_name, provider, object.schema)

2) Privileges:

PRIVILEGE.SET(conn, object_type, grantee, object_name,
privileges_without_grant, privileges_with_grant,
            object.schema)

PRIVILEGE.UNSETALL(conn, object_type, grantee, object_name, schema)

privileges_without_grant = comma separated string of privileges.
privileges_with_grant = comma separated string of privileges.
pull/3/head
Harshal Dhumal 2016-03-03 15:12:37 +00:00 committed by Dave Page
parent 3ff06da772
commit d2e372114b
2 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,14 @@
{##########################################}
{# Macros for schema and its child nodes #}
{##########################################}
{% macro SET(conn, type, role, param, priv, with_grant, schema) -%}
{% if priv %}
GRANT {{ priv }} ON {{ type }} {{ conn|qtIdent(schema, param) }} TO {{ conn|qtIdent(role) }};
{% endif %}
{% if with_grant %}
GRANT {{ with_grant }} ON {{ type }} {{ conn|qtIdent(schema, param) }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
{% endif %}
{%- endmacro %}
{% macro UNSETALL(conn, type, role, param, schema) -%}
REVOKE ALL ON {{ type }} {{ conn|qtIdent(schema, param) }} FROM {{ conn|qtIdent(role) }};
{%- endmacro %}

View File

@ -0,0 +1,9 @@
{##########################################}
{# Macros for schema and its child nodes #}
{##########################################}
{% macro SET(conn, type, name, provider, label, schema) -%}
SECURITY LABEL FOR {{ provider }} ON {{ type }} {{ conn|qtIdent(schema, name) }} IS {{ label|qtLiteral }};
{%- endmacro %}
{% macro UNSET(conn, type, name, provider, schema) -%}
SECURITY LABEL FOR {{ provider }} ON {{ type }} {{ conn|qtIdent(schema, name) }} IS NULL;
{%- endmacro %}