Unix Technical Forum

Re: Allow GRANT/REVOKE permissions to be applied to all schema objects with one command

This is a discussion on Re: Allow GRANT/REVOKE permissions to be applied to all schema objects with one command within the pgsql Hackers forums, part of the PostgreSQL category; --> Hi everybody, I thought a little bit on possible GRANT syntax for granting to groups of objects. In general, ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-11-2008, 03:30 AM
Matthias Schmidt
 
Posts: n/a
Default Re: Allow GRANT/REVOKE permissions to be applied to all schema objects with one command

Hi everybody,

I thought a little bit on possible GRANT syntax for granting to groups
of objects.

In general, we have the following entities we can grant permissions to:

1. TABLE
2. DATABASE
3. FUNCTION
4. LANGUAGE
5. SCHEMA
6. TABLESPACE

since the requirement is to grant to all objects in a given schema
(hope this still holds true) we are interested in:

TABLE
FUNCTION
LANGUAGE

The others (DATABASE, SCHEMA, TABLESPACE) are basically ruled out. I
suspect that the majority of users like to grant to TABLE's and
FUNCTIONS most of the time rather than LANGUAGE (correct me if i'm
wrong).

This reduces the question to TABLE's and probably FUNCTION's. Now we
have two choices:

a) accept some sort of wildcard for the grant on table syntax:
GRANT ... ON TABLE schema.*

b) use something like CASCADE for the grant on schema syntax:
GRANT ... ON SCHEMA CASCADE
In this case the grant on schema's need to swallow the permissions
(SELECT, INSERT, UPDATE ...) which are intended for TABLES. This
seems to me
kind of strange.

therefore I vote for Syntax a)

What do you think?

cheers,

Matthias



> Hi Tom + *,
>
> as I learned from severall posts this TODO splits into two distinct
> TODO's
>
> TODO1: Allow GRANT/REVOKE permissions to be applied to all schema
> objects with one command.
> TODO2: Assign Permissions to schemas wich get automatically inherited
> by objects created in the schema.
>
> my questions are:
>
> a) should we pursue both of them?
> b) how can a syntax for TODO1 look like? Anchored at 'GRANT ... ON
> SCHEMA' or 'GRANT ... ON <objecttype>' ?
>
> greetings,
>
> Matthias
>
> ----------------------------------------------------------------------
> Matthias Schmidt
> Viehtriftstr. 49
>
> 67346 Speyer
> GERMANY
>
> Tel.: +49 6232 4867
> Fax.: +49 6232 640089
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>
>

----------------------------------------------------------------------
Matthias Schmidt
Viehtriftstr. 49

67346 Speyer
GERMANY

Tel.: +49 6232 4867
Fax.: +49 6232 640089


---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-11-2008, 03:30 AM
Bruno Wolff III
 
Posts: n/a
Default Re: Allow GRANT/REVOKE permissions to be applied to all schema objects with one command

On Fri, Jan 28, 2005 at 21:17:46 +0100,
Matthias Schmidt <schmidtm@mock-software.de> wrote:
> Hi everybody,
>
> I thought a little bit on possible GRANT syntax for granting to groups
> of objects.
>
> In general, we have the following entities we can grant permissions to:
>
> 1. TABLE
> 2. DATABASE
> 3. FUNCTION
> 4. LANGUAGE
> 5. SCHEMA
> 6. TABLESPACE


You left out SEQUENCES.

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-11-2008, 03:30 AM
Alvaro Herrera
 
Posts: n/a
Default Re: Allow GRANT/REVOKE permissions to be applied to all schema objects with one command

On Fri, Jan 28, 2005 at 09:17:46PM +0100, Matthias Schmidt wrote:

> a) accept some sort of wildcard for the grant on table syntax:
> GRANT ... ON TABLE schema.*


What about a list,

GRANT ... ON TABLE table1, table2, ... TO user1, user2, ...;

It would be good if it was a list of wildcards. Not sure if that is
workable.

--
Alvaro Herrera (<alvherre[@]dcc.uchile.cl>)
"La fuerza no está en los medios físicos
sino que reside en una voluntad indomable" (Gandhi)

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-11-2008, 03:30 AM
Kevin Brown
 
Posts: n/a
Default Re: Allow GRANT/REVOKE permissions to be applied to all schema objects with one command

Alvaro Herrera wrote:
> On Fri, Jan 28, 2005 at 09:17:46PM +0100, Matthias Schmidt wrote:
>
> > a) accept some sort of wildcard for the grant on table syntax:
> > GRANT ... ON TABLE schema.*

>
> What about a list,
>
> GRANT ... ON TABLE table1, table2, ... TO user1, user2, ...;
>
> It would be good if it was a list of wildcards. Not sure if that is
> workable.


Actually, what I'd *love* to see is for statements such as GRANT to
allow select result sets to be used in place of arguments, e.g.:

GRANT ... ON TABLE (SELECT table_schema || '.' || table_name FROM
information_schema.tables WHERE table_schema IN ('public', 'postgres'))
TO (SELECT usename from PG_USER WHERE usecatupd = true);


Actually, it would be very nice if all DDL statements could work that
way.


--
Kevin Brown kevin@sysexperts.com

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-11-2008, 03:31 AM
Tom Lane
 
Posts: n/a
Default Re: Allow GRANT/REVOKE permissions to be applied to all schema objects with one command

Alvaro Herrera <alvherre@dcc.uchile.cl> writes:
> What about a list,


> GRANT ... ON TABLE table1, table2, ... TO user1, user2, ...;


We already allow a list (and have since at least 7.0).

> It would be good if it was a list of wildcards.


I'm a bit itchy about allowing wildcards --- it doesn't seem to fit well
with SQL syntax. The idea of allowing a subselect that returns a set of
names seems cleaner, though I'm not totally sure what to do to make it
schema-proof. I don't much like the idea that it returns a set of
strings that we then parse as possibly-quoted identifiers --- that opens
all sorts of traps for the unwary who forget to use quote_ident etc.

It would be unambiguous to make the subselect return a set of OIDs, eg

GRANT SELECT ON TABLE (SELECT oid FROM pg_class
WHERE relname LIKE 'some-pattern') TO ...

but exposing OIDs like this seems mighty bletcherous too, not to mention
not very easy to use for someone not intimately familiar with the system
catalog layout.

Josh's last suggestion (ALL TABLES IN someschema) seems to me to be a
reasonable compromise between usefulness, syntactic weirdness, and
hiding implementation details.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-11-2008, 03:31 AM
Jim C. Nasby
 
Posts: n/a
Default Re: Allow GRANT/REVOKE permissions to be applied to all schema objects with one command

On Sat, Jan 29, 2005 at 12:01:09AM -0500, Tom Lane wrote:
> Alvaro Herrera <alvherre@dcc.uchile.cl> writes:
> > What about a list,

>
> > GRANT ... ON TABLE table1, table2, ... TO user1, user2, ...;

>
> We already allow a list (and have since at least 7.0).
>
> > It would be good if it was a list of wildcards.

>
> I'm a bit itchy about allowing wildcards --- it doesn't seem to fit well
> with SQL syntax. The idea of allowing a subselect that returns a set of
> names seems cleaner, though I'm not totally sure what to do to make it
> schema-proof. I don't much like the idea that it returns a set of
> strings that we then parse as possibly-quoted identifiers --- that opens
> all sorts of traps for the unwary who forget to use quote_ident etc.
>
> It would be unambiguous to make the subselect return a set of OIDs, eg
>
> GRANT SELECT ON TABLE (SELECT oid FROM pg_class
> WHERE relname LIKE 'some-pattern') TO ...
>
> but exposing OIDs like this seems mighty bletcherous too, not to mention
> not very easy to use for someone not intimately familiar with the system
> catalog layout.


FWIW, I like the subselect idea. What if there was some kind of column
or function added that returned the data as the command needed it?
Something like ( quote_ident(schema_name) || '.' ||
quote_ident(table_name) ) AS object_id.

Is there a way to go from an OID to a named identifier? That might make
it easier, though I guess it's still kindof exposing OID.
--
Jim C. Nasby, Database Consultant decibel@decibel.org
Give your computer some brain candy! www.distributed.net Team #1828

Windows: "Where do you want to go today?"
Linux: "Where do you want to go tomorrow?"
FreeBSD: "Are you guys coming, or what?"

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:12 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com