public inbox for [email protected]
help / color / mirror / Atom feedPATCH: To fix issue using PUBLIC as role (pgAdmin4)
2+ messages / 2 participants
[nested] [flat]
* PATCH: To fix issue using PUBLIC as role (pgAdmin4)
@ 2016-07-13 10:40 Murtuza Zabuawala <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Murtuza Zabuawala @ 2016-07-13 10:40 UTC (permalink / raw)
To: pgadmin-hackers
Hi,
PFA patch to fix the issue where user was not able to select 'PUBLIC' as
role in privileges.
(RM#1416)
This issue was due to previous commit: b78b3904cd7e5a8edf
--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers
Attachments:
[application/octet-stream] RM_1416.patch (10.5K, 3-RM_1416.patch)
download | inline diff:
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/templates/column/macros/privilege.macros b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/templates/column/macros/privilege.macros
index 7eafd60..7fe81e5 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/templates/column/macros/privilege.macros
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/column/templates/column/macros/privilege.macros
@@ -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 %}
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/macros/privilege.macros b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/macros/privilege.macros
index 7eafd60..7fe81e5 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/macros/privilege.macros
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/column/macros/privilege.macros
@@ -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 %}
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/functions/privilege.macros b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/functions/privilege.macros
index 08d1198..3a55908 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/functions/privilege.macros
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/functions/privilege.macros
@@ -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 %}
diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/schemas/privilege.macros b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/schemas/privilege.macros
index dc18a31..5211b00 100644
--- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/schemas/privilege.macros
+++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/macros/schemas/privilege.macros
@@ -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 %}
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/templates/macros/default_privilege.macros b/web/pgadmin/browser/server_groups/servers/templates/macros/default_privilege.macros
index 5135d61..6372d6b 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/macros/default_privilege.macros
+++ b/web/pgadmin/browser/server_groups/servers/templates/macros/default_privilege.macros
@@ -1,29 +1,29 @@
{% macro APPLY(conn, type, role, privs, with_grant_privs) -%}
{% if privs %}
ALTER DEFAULT PRIVILEGES
-GRANT {{ privs|join(', ') }} ON {{ type }} TO {{ conn|qtIdent(role) }};
+GRANT {{ privs|join(', ') }} ON {{ type }} TO {{ role }};
{% endif %}
{% if with_grant_privs %}
ALTER DEFAULT PRIVILEGES
-GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
+GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} TO {{ role }} WITH GRANT OPTION;
{% endif %}
{%- endmacro %}
{% macro RESETALL(conn, type, role) -%}
ALTER DEFAULT PRIVILEGES
- REVOKE ALL ON {{ type }} FROM {{ conn|qtIdent(role) }};
+ REVOKE ALL ON {{ type }} FROM {{ role }};
{%- endmacro %}
{### To allow create macro for specific database object ###}
{% macro SET(conn, db_object_type, db_object_name, type, role, privs, with_grant_privs) -%}
{% if privs %}
ALTER DEFAULT PRIVILEGES IN {{ db_object_type }} {{ conn|qtIdent(db_object_name) }}
-GRANT {{ privs|join(', ') }} ON {{ type }} TO {{ conn|qtIdent(role) }};
+GRANT {{ privs|join(', ') }} ON {{ type }} TO {{ role }};
{% endif %}
{% if with_grant_privs %}
ALTER DEFAULT PRIVILEGES IN {{ db_object_type }} {{ conn|qtIdent(db_object_name) }}
-GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
+GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} TO {{ role }} WITH GRANT OPTION;
{% endif %}
{%- endmacro %}
{% macro UNSET(conn, db_object_type, db_object_name, type, role) -%}
ALTER DEFAULT PRIVILEGES IN {{ db_object_type }} {{ conn|qtIdent(db_object_name) }}
- REVOKE ALL ON {{ type }} FROM {{ conn|qtIdent(role) }};
+ REVOKE ALL ON {{ type }} FROM {{ role }};
{%- endmacro %}
diff --git a/web/pgadmin/browser/server_groups/servers/templates/macros/privilege.macros b/web/pgadmin/browser/server_groups/servers/templates/macros/privilege.macros
index 31b5e38..77ec540 100644
--- a/web/pgadmin/browser/server_groups/servers/templates/macros/privilege.macros
+++ b/web/pgadmin/browser/server_groups/servers/templates/macros/privilege.macros
@@ -1,11 +1,11 @@
{% macro APPLY(conn, type, role, param, privs, with_grant_privs) -%}
{% if privs %}
-GRANT {{ privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(param) }} TO {{ conn|qtIdent(role) }};
+GRANT {{ privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(param) }} TO {{ role }};
{% endif %}
{% if with_grant_privs %}
-GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(param) }} TO {{ conn|qtIdent(role) }} WITH GRANT OPTION;
+GRANT {{ with_grant_privs|join(', ') }} ON {{ type }} {{ conn|qtIdent(param) }} TO {{ role }} WITH GRANT OPTION;
{% endif %}
{%- endmacro %}
{% macro RESETALL(conn, type, role, param) -%}
-REVOKE ALL ON {{ type }} {{ conn|qtIdent(param) }} FROM {{ conn|qtIdent(role) }};
+REVOKE ALL ON {{ type }} {{ conn|qtIdent(param) }} FROM {{ role }};
{%- endmacro %}
\ No newline at end of file
diff --git a/web/pgadmin/browser/server_groups/servers/utils.py b/web/pgadmin/browser/server_groups/servers/utils.py
index 02fab9e..356b808 100644
--- a/web/pgadmin/browser/server_groups/servers/utils.py
+++ b/web/pgadmin/browser/server_groups/servers/utils.py
@@ -37,6 +37,10 @@ def parse_priv_to_db(str_privileges, allowed_acls=[]):
"""
Common utility function to parse privileges before sending to database.
"""
+ from pgadmin.utils.driver import get_driver
+ from config import PG_DEFAULT_DRIVER
+ driver = get_driver(PG_DEFAULT_DRIVER)
+
db_privileges = {
'c': 'CONNECT',
'C': 'CREATE',
@@ -82,7 +86,8 @@ def parse_priv_to_db(str_privileges, allowed_acls=[]):
priv_without_grant = ['ALL']
# Appending and returning all ACL
privileges.append({
- 'grantee': priv['grantee'],
+ 'grantee': driver.qtIdent(None, priv['grantee'])
+ if priv['grantee'] != 'PUBLIC' else 'PUBLIC',
'with_grant': priv_with_grant,
'without_grant': priv_without_grant
})
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: PATCH: To fix issue using PUBLIC as role (pgAdmin4)
@ 2016-07-13 13:51 Dave Page <[email protected]>
parent: Murtuza Zabuawala <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Dave Page @ 2016-07-13 13:51 UTC (permalink / raw)
To: Murtuza Zabuawala <[email protected]>; +Cc: pgadmin-hackers
Thanks, applied.
On Wed, Jul 13, 2016 at 11:40 AM, Murtuza Zabuawala
<[email protected]> wrote:
> Hi,
>
> PFA patch to fix the issue where user was not able to select 'PUBLIC' as
> role in privileges.
> (RM#1416)
>
> This issue was due to previous commit: b78b3904cd7e5a8edf
>
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>
> --
> Sent via pgadmin-hackers mailing list ([email protected])
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2016-07-13 13:51 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-07-13 10:40 PATCH: To fix issue using PUBLIC as role (pgAdmin4) Murtuza Zabuawala <[email protected]>
2016-07-13 13:51 ` Dave Page <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox