Ensure that Grant Wizard should include foreign tables. Fixes #5959
parent
3a38f6b147
commit
64964f82cf
docs/en_US
web/pgadmin/tools/grant_wizard
static/js
templates/grant_wizard
pg/9.1_plus
ppas/9.1_plus
|
@ -35,3 +35,4 @@ Bug fixes
|
||||||
| `Issue #5923 <https://redmine.postgresql.org/issues/5923>`_ - Fixed an issue where non-closeable tabs are getting closed.
|
| `Issue #5923 <https://redmine.postgresql.org/issues/5923>`_ - Fixed an issue where non-closeable tabs are getting closed.
|
||||||
| `Issue #5950 <https://redmine.postgresql.org/issues/5950>`_ - Fixed an issue where a long file name is not visible on the process watcher dialog.
|
| `Issue #5950 <https://redmine.postgresql.org/issues/5950>`_ - Fixed an issue where a long file name is not visible on the process watcher dialog.
|
||||||
| `Issue #5953 <https://redmine.postgresql.org/issues/5953>`_ - Fixed an issue where connection to the server is on wait state if a different user is provided.
|
| `Issue #5953 <https://redmine.postgresql.org/issues/5953>`_ - Fixed an issue where connection to the server is on wait state if a different user is provided.
|
||||||
|
| `Issue #5959 <https://redmine.postgresql.org/issues/5959>`_ - Ensure that Grant Wizard should include foreign tables.
|
||||||
|
|
|
@ -243,6 +243,13 @@ def _get_rows_for_type(conn, ntype, server_prop, node_id):
|
||||||
node_id=node_id, node_type='m')
|
node_id=node_id, node_type='m')
|
||||||
|
|
||||||
status, res = conn.execute_dict(sql)
|
status, res = conn.execute_dict(sql)
|
||||||
|
# Fetch Foreign tables.
|
||||||
|
elif ntype in ['foreign_table']:
|
||||||
|
sql = render_template("/".join(
|
||||||
|
[server_prop['template_path'], '/sql/foreign_table.sql']),
|
||||||
|
node_id=node_id, node_type='m')
|
||||||
|
|
||||||
|
status, res = conn.execute_dict(sql)
|
||||||
|
|
||||||
return status, res
|
return status, res
|
||||||
|
|
||||||
|
@ -327,6 +334,10 @@ def properties(sid, did, node_id, node_type):
|
||||||
status, res = _get_rows_for_type(
|
status, res = _get_rows_for_type(
|
||||||
conn, 'mview', server_prop, node_id)
|
conn, 'mview', server_prop, node_id)
|
||||||
_append_rows(status, res, 'materialized view')
|
_append_rows(status, res, 'materialized view')
|
||||||
|
|
||||||
|
status, res = _get_rows_for_type(
|
||||||
|
conn, 'foreign_table', server_prop, node_id)
|
||||||
|
_append_rows(status, res, 'foreign table')
|
||||||
else:
|
else:
|
||||||
status, res = _get_rows_for_type(conn, ntype, server_prop, node_id)
|
status, res = _get_rows_for_type(conn, ntype, server_prop, node_id)
|
||||||
_append_rows(status, res, 'function')
|
_append_rows(status, res, 'function')
|
||||||
|
@ -386,6 +397,10 @@ def msql(sid, did):
|
||||||
data['acl'],
|
data['acl'],
|
||||||
acls['table']['acl'])
|
acls['table']['acl'])
|
||||||
|
|
||||||
|
data['priv']['foreign_table'] = parse_priv_to_db(
|
||||||
|
data['acl'],
|
||||||
|
acls['foreign_table']['acl'])
|
||||||
|
|
||||||
# Pass database objects and get SQL for privileges
|
# Pass database objects and get SQL for privileges
|
||||||
sql_data = ''
|
sql_data = ''
|
||||||
data_func = {'objects': data['objects'],
|
data_func = {'objects': data['objects'],
|
||||||
|
@ -414,6 +429,15 @@ def msql(sid, did):
|
||||||
if sql and sql.strip('\n') != '':
|
if sql and sql.strip('\n') != '':
|
||||||
sql_data += sql
|
sql_data += sql
|
||||||
|
|
||||||
|
data_table = {'objects': data['objects'],
|
||||||
|
'priv': data['priv']['foreign_table']}
|
||||||
|
sql = render_template(
|
||||||
|
"/".join([server_prop['template_path'],
|
||||||
|
'/sql/grant_foreign_table.sql']),
|
||||||
|
data=data_table, conn=conn)
|
||||||
|
if sql and sql.strip('\n') != '':
|
||||||
|
sql_data += sql
|
||||||
|
|
||||||
res = {'data': sql_data}
|
res = {'data': sql_data}
|
||||||
|
|
||||||
return ajax_response(
|
return ajax_response(
|
||||||
|
@ -473,6 +497,10 @@ def save(sid, did):
|
||||||
data['acl'],
|
data['acl'],
|
||||||
acls['table']['acl'])
|
acls['table']['acl'])
|
||||||
|
|
||||||
|
data['priv']['foreign_table'] = parse_priv_to_db(
|
||||||
|
data['acl'],
|
||||||
|
acls['foreign_table']['acl'])
|
||||||
|
|
||||||
# Pass database objects and get SQL for privileges
|
# Pass database objects and get SQL for privileges
|
||||||
# Pass database objects and get SQL for privileges
|
# Pass database objects and get SQL for privileges
|
||||||
sql_data = ''
|
sql_data = ''
|
||||||
|
@ -502,6 +530,15 @@ def save(sid, did):
|
||||||
if sql and sql.strip('\n') != '':
|
if sql and sql.strip('\n') != '':
|
||||||
sql_data += sql
|
sql_data += sql
|
||||||
|
|
||||||
|
data_table = {'objects': data['objects'],
|
||||||
|
'priv': data['priv']['foreign_table']}
|
||||||
|
sql = render_template(
|
||||||
|
"/".join([server_prop['template_path'],
|
||||||
|
'/sql/grant_foreign_table.sql']),
|
||||||
|
data=data_table, conn=conn)
|
||||||
|
if sql and sql.strip('\n') != '':
|
||||||
|
sql_data += sql
|
||||||
|
|
||||||
status, res = conn.execute_dict(sql_data)
|
status, res = conn.execute_dict(sql_data)
|
||||||
if not status:
|
if not status:
|
||||||
return internal_server_error(errormsg=res)
|
return internal_server_error(errormsg=res)
|
||||||
|
|
|
@ -539,6 +539,9 @@ define([
|
||||||
case 'Materialized View':
|
case 'Materialized View':
|
||||||
object_type = 'table';
|
object_type = 'table';
|
||||||
break;
|
break;
|
||||||
|
case 'Foreign Table':
|
||||||
|
object_type = 'foreign_table';
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,10 @@
|
||||||
"type": "TABLE",
|
"type": "TABLE",
|
||||||
"acl": ["a", "r", "w", "d", "D", "x", "t"]
|
"acl": ["a", "r", "w", "d", "D", "x", "t"]
|
||||||
},
|
},
|
||||||
|
"foreign_table": {
|
||||||
|
"type": "FOREIGN TABLE",
|
||||||
|
"acl": ["a", "r", "w","x"]
|
||||||
|
},
|
||||||
"sequence": {
|
"sequence": {
|
||||||
"type": "SEQUENCE",
|
"type": "SEQUENCE",
|
||||||
"acl": ["r", "w", "U"]
|
"acl": ["r", "w", "U"]
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
{# ===== Fetch list of Database object types(Tables) ===== #}
|
||||||
|
{% if node_id %}
|
||||||
|
SELECT
|
||||||
|
rel.relname AS name,
|
||||||
|
nsp.nspname AS nspname,
|
||||||
|
'Foreign Table' AS object_type,
|
||||||
|
'icon-coll-foreign_table' AS icon
|
||||||
|
FROM
|
||||||
|
pg_class rel
|
||||||
|
JOIN pg_namespace nsp ON nsp.oid=rel.relnamespace
|
||||||
|
|
||||||
|
WHERE
|
||||||
|
rel.relkind IN ('f') AND rel.relnamespace = {{ node_id }}::oid
|
||||||
|
ORDER BY
|
||||||
|
rel.relname
|
||||||
|
{% endif %}
|
|
@ -0,0 +1,9 @@
|
||||||
|
{# ===== Grant Permissions on Database Objects Selected ==== #}
|
||||||
|
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||||
|
{% for obj in data.objects -%}
|
||||||
|
{% for priv in data.priv -%}
|
||||||
|
{% if obj.object_type == 'Foreign Table' %}
|
||||||
|
{{ PRIVILEGE.SET(conn, 'TABLE', priv['grantee'], obj.name, priv['without_grant'], priv['with_grant'], obj.nspname ) }}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor -%}
|
||||||
|
{% endfor -%}
|
|
@ -15,6 +15,10 @@
|
||||||
"type": "TABLE",
|
"type": "TABLE",
|
||||||
"acl": ["a", "r", "w", "d", "D", "x", "t"]
|
"acl": ["a", "r", "w", "d", "D", "x", "t"]
|
||||||
},
|
},
|
||||||
|
"foreign_table": {
|
||||||
|
"type": "FOREIGN TABLE",
|
||||||
|
"acl": ["a", "r", "w","x"]
|
||||||
|
},
|
||||||
"sequence": {
|
"sequence": {
|
||||||
"type": "SEQUENCE",
|
"type": "SEQUENCE",
|
||||||
"acl": ["r", "w", "U"]
|
"acl": ["r", "w", "U"]
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
{# ===== Fetch list of Database object types(Tables) ===== #}
|
||||||
|
{% if node_id %}
|
||||||
|
SELECT
|
||||||
|
rel.relname AS name,
|
||||||
|
nsp.nspname AS nspname,
|
||||||
|
'Foreign Table' AS object_type,
|
||||||
|
'icon-coll-foreign_table' AS icon
|
||||||
|
FROM
|
||||||
|
pg_class rel
|
||||||
|
JOIN pg_namespace nsp ON nsp.oid=rel.relnamespace
|
||||||
|
|
||||||
|
WHERE
|
||||||
|
rel.relkind IN ('f') AND rel.relnamespace = {{ node_id }}::oid
|
||||||
|
ORDER BY
|
||||||
|
rel.relname
|
||||||
|
{% endif %}
|
|
@ -0,0 +1,9 @@
|
||||||
|
{# ===== Grant Permissions on Database Objects Selected ==== #}
|
||||||
|
{% import 'macros/schemas/privilege.macros' as PRIVILEGE %}
|
||||||
|
{% for obj in data.objects -%}
|
||||||
|
{% for priv in data.priv -%}
|
||||||
|
{% if obj.object_type == 'Foreign Table' %}
|
||||||
|
{{ PRIVILEGE.SET(conn, 'TABLE', priv['grantee'], obj.name, priv['without_grant'], priv['with_grant'], obj.nspname ) }}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor -%}
|
||||||
|
{% endfor -%}
|
Loading…
Reference in New Issue