Allow selection of 'PUBLIC' as a role in privileges. Fixes #1416

This commit is contained in:
Murtuza Zabuawala
2016-07-13 14:51:25 +01:00
committed by Dave Page
parent ae692d2416
commit f79ca32e45
7 changed files with 27 additions and 22 deletions
@@ -1,13 +1,13 @@
{% macro APPLY(conn, schema_name, table_object, column_object, role, privs, with_grant_privs) -%}
{% if privs %}
GRANT {% for p in privs %}{% if loop.index != 1 %}, {% endif %}{{p}}({{conn|qtIdent(column_object)}}){% endfor %}
ON {{ conn|qtIdent(schema_name, table_object) }} TO {{ conn|qtIdent(role) }};
ON {{ conn|qtIdent(schema_name, table_object) }} TO {{ role }};
{% endif %}
{% if with_grant_privs %}
GRANT {% for p in with_grant_privs %}{% if loop.index != 1 %}, {% endif %}{{p}}({{conn|qtIdent(column_object)}}){% endfor %}
ON {{ conn|qtIdent(schema_name, table_object) }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
ON {{ conn|qtIdent(schema_name, table_object) }} TO {{ role }} WITH GRANT OPTION;
{% endif %}
{%- endmacro %}
{% macro RESETALL(conn, schema_name, table_object, column_object, role) -%}
REVOKE ALL({{ conn|qtIdent(column_object) }}) ON {{ conn|qtIdent(schema_name, table_object) }} FROM {{ conn|qtIdent(role) }};
REVOKE ALL({{ conn|qtIdent(column_object) }}) ON {{ conn|qtIdent(schema_name, table_object) }} FROM {{ role }};
{%- endmacro %}
@@ -1,13 +1,13 @@
{% macro APPLY(conn, schema_name, table_object, column_object, role, privs, with_grant_privs) -%}
{% if privs %}
GRANT {% for p in privs %}{% if loop.index != 1 %}, {% endif %}{{p}}({{conn|qtIdent(column_object)}}){% endfor %}
ON {{ conn|qtIdent(schema_name, table_object) }} TO {{ conn|qtIdent(role) }};
ON {{ conn|qtIdent(schema_name, table_object) }} TO {{ role }};
{% endif %}
{% if with_grant_privs %}
GRANT {% for p in with_grant_privs %}{% if loop.index != 1 %}, {% endif %}{{p}}({{conn|qtIdent(column_object)}}){% endfor %}
ON {{ conn|qtIdent(schema_name, table_object) }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
ON {{ conn|qtIdent(schema_name, table_object) }} TO {{ role }} WITH GRANT OPTION;
{% endif %}
{%- endmacro %}
{% macro RESETALL(conn, schema_name, table_object, column_object, role) -%}
REVOKE ALL({{ conn|qtIdent(column_object) }}) ON {{ conn|qtIdent(schema_name, table_object) }} FROM {{ conn|qtIdent(role) }};
REVOKE ALL({{ conn|qtIdent(column_object) }}) ON {{ conn|qtIdent(schema_name, table_object) }} FROM {{ role }};
{%- endmacro %}
@@ -3,12 +3,12 @@
{##############################################}
{% macro SET(conn, type, role, param, privs, with_grant_privs, schema, func_args) -%}
{% if privs %}
GRANT {{ privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(schema, param) }}({{func_args}}) TO {{conn|qtIdent(role) }};
GRANT {{ privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(schema, param) }}({{func_args}}) TO {{role }};
{% endif %}
{% if with_grant_privs %}
GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(schema, param) }}({{func_args}}) TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(schema, param) }}({{func_args}}) TO {{ role }} WITH GRANT OPTION;
{% endif %}
{%- endmacro %}
{% macro UNSETALL(conn, type, role, param, schema, func_args) -%}
REVOKE ALL ON {{ type }} {{ conn|qtIdent(schema, param) }}({{func_args}}) FROM {{conn|qtIdent(role) }};
REVOKE ALL ON {{ type }} {{ conn|qtIdent(schema, param) }}({{func_args}}) FROM {{role }};
{%- endmacro %}
@@ -3,16 +3,16 @@
{##########################################}
{% macro SET(conn, type, role, param, privs, with_grant_privs, schema) -%}
{% if privs %}
GRANT {{ privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(schema, param) }} TO {{ conn|qtIdent(role) }};
GRANT {{ privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(schema, param) }} TO {{ role }};
{% endif %}
{% if with_grant_privs %}
{% if privs %}
{# This empty if is to add new line in between #}
{% endif %}
GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(schema, param) }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(schema, param) }} TO {{ 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) }};
REVOKE ALL ON {{ type }} {{ conn|qtIdent(schema, param) }} FROM {{ role }};
{%- endmacro %}