pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedBacking out of privilege grants rabbit hole
11+ messages / 6 participants
[nested] [flat]
* Backing out of privilege grants rabbit hole
@ 2020-04-03 03:34 AC Gomez <antklc@gmail.com>
0 siblings, 1 reply; 11+ messages in thread
From: AC Gomez @ 2020-04-03 03:34 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Do I understand correctly that if a role was assigned countless object
privileges and you want to delete that role you have to sift through a
myriad of privilege grants in what amounts to a time consuming trial and
error exercise until you've got them all?
Or is there a single command that with just delete the role and do a
blanket grant removal at the same time?
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Backing out of privilege grants rabbit hole
@ 2020-04-03 03:37 Guyren Howe <guyren@gmail.com>
parent: AC Gomez <antklc@gmail.com>
0 siblings, 2 replies; 11+ messages in thread
From: Guyren Howe @ 2020-04-03 03:37 UTC (permalink / raw)
To: AC Gomez <antklc@gmail.com>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
https://www.postgresql.org/docs/12/sql-drop-owned.html <https://www.postgresql.org/docs/12/sql-drop-owned.html;
> On Apr 2, 2020, at 20:34 , AC Gomez <antklc@gmail.com> wrote:
>
> Do I understand correctly that if a role was assigned countless object privileges and you want to delete that role you have to sift through a myriad of privilege grants in what amounts to a time consuming trial and error exercise until you've got them all?
>
> Or is there a single command that with just delete the role and do a blanket grant removal at the same time?
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Backing out of privilege grants rabbit hole
@ 2020-04-03 03:41 Guyren Howe <guyren@gmail.com>
parent: Guyren Howe <guyren@gmail.com>
1 sibling, 0 replies; 11+ messages in thread
From: Guyren Howe @ 2020-04-03 03:41 UTC (permalink / raw)
To: AC Gomez <antklc@gmail.com>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
More fully:
REASSIGN OWNED BY doomed_role TO successor_role;
DROP OWNED BY doomed_role;
-- repeat the above commands in each database of the cluster
DROP ROLE doomed_role;
> On Apr 2, 2020, at 20:37 , Guyren Howe <guyren@gmail.com> wrote:
>
> https://www.postgresql.org/docs/12/sql-drop-owned.html <https://www.postgresql.org/docs/12/sql-drop-owned.html;
>
>> On Apr 2, 2020, at 20:34 , AC Gomez <antklc@gmail.com <mailto:antklc@gmail.com>> wrote:
>>
>> Do I understand correctly that if a role was assigned countless object privileges and you want to delete that role you have to sift through a myriad of privilege grants in what amounts to a time consuming trial and error exercise until you've got them all?
>>
>> Or is there a single command that with just delete the role and do a blanket grant removal at the same time?
>>
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Backing out of privilege grants rabbit hole
@ 2020-04-03 03:42 AC Gomez <antklc@gmail.com>
parent: Guyren Howe <guyren@gmail.com>
1 sibling, 1 reply; 11+ messages in thread
From: AC Gomez @ 2020-04-03 03:42 UTC (permalink / raw)
To: Guyren Howe <guyren@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
Thanks for the quick response. The problem is, in most cases the owner is
not the grantee. So if a role, let's say a temp employee, gets grants, then
leaves, I can't do a drop owned because that temp never owned those
objects, he just was granted access. Is there a "drop granted" kind of
thing?
On Thu, Apr 2, 2020, 11:37 PM Guyren Howe <guyren@gmail.com> wrote:
> https://www.postgresql.org/docs/12/sql-drop-owned.html
>
> On Apr 2, 2020, at 20:34 , AC Gomez <antklc@gmail.com> wrote:
>
> Do I understand correctly that if a role was assigned countless object
> privileges and you want to delete that role you have to sift through a
> myriad of privilege grants in what amounts to a time consuming trial and
> error exercise until you've got them all?
>
> Or is there a single command that with just delete the role and do a
> blanket grant removal at the same time?
>
>
>
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Backing out of privilege grants rabbit hole
@ 2020-04-03 04:57 raf <raf@raf.org>
parent: AC Gomez <antklc@gmail.com>
0 siblings, 1 reply; 11+ messages in thread
From: raf @ 2020-04-03 04:57 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
It's probably more sensible to grant permissions to roles that
represent groups, and have roles for individual users that
inherit the permissions of the group roles. Then you don't
need to revoke the permissions just because an individiual
has left.
cheers,
raf
AC Gomez wrote:
> Thanks for the quick response. The problem is, in most cases the owner is
> not the grantee. So if a role, let's say a temp employee, gets grants, then
> leaves, I can't do a drop owned because that temp never owned those
> objects, he just was granted access. Is there a "drop granted" kind of
> thing?
>
> On Thu, Apr 2, 2020, 11:37 PM Guyren Howe <guyren@gmail.com> wrote:
>
> > https://www.postgresql.org/docs/12/sql-drop-owned.html
> >
> > On Apr 2, 2020, at 20:34 , AC Gomez <antklc@gmail.com> wrote:
> >
> > Do I understand correctly that if a role was assigned countless object
> > privileges and you want to delete that role you have to sift through a
> > myriad of privilege grants in what amounts to a time consuming trial and
> > error exercise until you've got them all?
> >
> > Or is there a single command that with just delete the role and do a
> > blanket grant removal at the same time?
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Backing out of privilege grants rabbit hole
@ 2020-04-03 04:59 AC Gomez <antklc@gmail.com>
parent: raf <raf@raf.org>
0 siblings, 2 replies; 11+ messages in thread
From: AC Gomez @ 2020-04-03 04:59 UTC (permalink / raw)
To: raf <raf@raf.org>; +Cc: pgsql-general@lists.postgresql.org
Granted. But we are where we are, so I'm assuming this is going to be hand
to hand combat.
On Fri, Apr 3, 2020, 12:57 AM raf <raf@raf.org> wrote:
> It's probably more sensible to grant permissions to roles that
> represent groups, and have roles for individual users that
> inherit the permissions of the group roles. Then you don't
> need to revoke the permissions just because an individiual
> has left.
>
> cheers,
> raf
>
> AC Gomez wrote:
>
> > Thanks for the quick response. The problem is, in most cases the owner is
> > not the grantee. So if a role, let's say a temp employee, gets grants,
> then
> > leaves, I can't do a drop owned because that temp never owned those
> > objects, he just was granted access. Is there a "drop granted" kind of
> > thing?
> >
> > On Thu, Apr 2, 2020, 11:37 PM Guyren Howe <guyren@gmail.com> wrote:
> >
> > > https://www.postgresql.org/docs/12/sql-drop-owned.html
> > >
> > > On Apr 2, 2020, at 20:34 , AC Gomez <antklc@gmail.com> wrote:
> > >
> > > Do I understand correctly that if a role was assigned countless object
> > > privileges and you want to delete that role you have to sift through a
> > > myriad of privilege grants in what amounts to a time consuming trial
> and
> > > error exercise until you've got them all?
> > >
> > > Or is there a single command that with just delete the role and do a
> > > blanket grant removal at the same time?
>
>
>
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Backing out of privilege grants rabbit hole
@ 2020-04-03 08:50 Laurenz Albe <laurenz.albe@cybertec.at>
parent: AC Gomez <antklc@gmail.com>
1 sibling, 1 reply; 11+ messages in thread
From: Laurenz Albe @ 2020-04-03 08:50 UTC (permalink / raw)
To: AC Gomez <antklc@gmail.com>; raf <raf@raf.org>; +Cc: pgsql-general@lists.postgresql.org
On Fri, 2020-04-03 at 00:59 -0400, AC Gomez wrote:
> Granted. But we are where we are, so I'm assuming this is going to be hand to hand combat.
Yes, unfortunately there is no better way.
But DROP ROLE will produce messages that help you along.
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Backing out of privilege grants rabbit hole
@ 2020-04-03 13:55 Rob Sargent <robjsargent@gmail.com>
parent: Laurenz Albe <laurenz.albe@cybertec.at>
0 siblings, 0 replies; 11+ messages in thread
From: Rob Sargent @ 2020-04-03 13:55 UTC (permalink / raw)
To: Laurenz Albe <laurenz.albe@cybertec.at>; +Cc: AC Gomez <antklc@gmail.com>; raf <raf@raf.org>; pgsql-general@lists.postgresql.org
> On Apr 3, 2020, at 2:50 AM, Laurenz Albe <laurenz.albe@cybertec.at> wrote:
>
> On Fri, 2020-04-03 at 00:59 -0400, AC Gomez wrote:
>> Granted. But we are where we are, so I'm assuming this is going to be hand to hand combat.
>
> Yes, unfortunately there is no better way.
> But DROP ROLE will produce messages that help you along.
>
> Yours,
> Laurenz Albe
> --
> Cybertec | https://www.cybertec-postgresql.com
>
>
Perhaps there is a script which has all the grants for a new hire?
I trust login has been disabled?
>
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Backing out of privilege grants rabbit hole
@ 2020-04-03 17:18 Adrian Klaver <adrian.klaver@aklaver.com>
parent: AC Gomez <antklc@gmail.com>
1 sibling, 1 reply; 11+ messages in thread
From: Adrian Klaver @ 2020-04-03 17:18 UTC (permalink / raw)
To: AC Gomez <antklc@gmail.com>; raf <raf@raf.org>; +Cc: pgsql-general@lists.postgresql.org
On 4/2/20 9:59 PM, AC Gomez wrote:
> Granted. But we are where we are, so I'm assuming this is going to be
> hand to hand combat.
Well you could even the odds somewhat by using the below as a starting
point:
SELECT
relname,
pg_roles.rolname,
acl.*
FROM
pg_class,
aclexplode(relacl) AS acl
JOIN pg_roles ON acl.grantee = pg_roles.oid
WHERE
pg_roles.oid = 'some_role'::regrole;
>
> On Fri, Apr 3, 2020, 12:57 AM raf <raf@raf.org <mailto:raf@raf.org>> wrote:
>
> It's probably more sensible to grant permissions to roles that
> represent groups, and have roles for individual users that
> inherit the permissions of the group roles. Then you don't
> need to revoke the permissions just because an individiual
> has left.
>
> cheers,
> raf
>
> AC Gomez wrote:
>
> > Thanks for the quick response. The problem is, in most cases the
> owner is
> > not the grantee. So if a role, let's say a temp employee, gets
> grants, then
> > leaves, I can't do a drop owned because that temp never owned those
> > objects, he just was granted access. Is there a "drop granted"
> kind of
> > thing?
> >
> > On Thu, Apr 2, 2020, 11:37 PM Guyren Howe <guyren@gmail.com
> <mailto:guyren@gmail.com>> wrote:
> >
> > > https://www.postgresql.org/docs/12/sql-drop-owned.html
> > >
> > > On Apr 2, 2020, at 20:34 , AC Gomez <antklc@gmail.com
> <mailto:antklc@gmail.com>> wrote:
> > >
> > > Do I understand correctly that if a role was assigned countless
> object
> > > privileges and you want to delete that role you have to sift
> through a
> > > myriad of privilege grants in what amounts to a time consuming
> trial and
> > > error exercise until you've got them all?
> > >
> > > Or is there a single command that with just delete the role and
> do a
> > > blanket grant removal at the same time?
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Backing out of privilege grants rabbit hole
@ 2020-04-03 17:23 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 1 reply; 11+ messages in thread
From: Adrian Klaver @ 2020-04-03 17:23 UTC (permalink / raw)
To: AC Gomez <antklc@gmail.com>; raf <raf@raf.org>; +Cc: pgsql-general@lists.postgresql.org
On 4/3/20 10:18 AM, Adrian Klaver wrote:
> On 4/2/20 9:59 PM, AC Gomez wrote:
>> Granted. But we are where we are, so I'm assuming this is going to be
>> hand to hand combat.
>
> Well you could even the odds somewhat by using the below as a starting
> point:
>
>
> SELECT
> relname,
> pg_roles.rolname,
> acl.*
> FROM
> pg_class,
> aclexplode(relacl) AS acl
> JOIN pg_roles ON acl.grantee = pg_roles.oid
> WHERE
> pg_roles.oid = 'some_role'::regrole;
>
Possible flaw in plan, the above only works with v12+.
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 11+ messages in thread
* Re: Backing out of privilege grants rabbit hole
@ 2020-04-03 17:29 AC Gomez <antklc@gmail.com>
parent: Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 0 replies; 11+ messages in thread
From: AC Gomez @ 2020-04-03 17:29 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: raf <raf@raf.org>; pgsql-general@lists.postgresql.org
yeah I'm on 9.5, but thanks for the info.
On Fri, Apr 3, 2020 at 1:24 PM Adrian Klaver <adrian.klaver@aklaver.com>
wrote:
> On 4/3/20 10:18 AM, Adrian Klaver wrote:
> > On 4/2/20 9:59 PM, AC Gomez wrote:
> >> Granted. But we are where we are, so I'm assuming this is going to be
> >> hand to hand combat.
> >
> > Well you could even the odds somewhat by using the below as a starting
> > point:
> >
> >
> > SELECT
> > relname,
> > pg_roles.rolname,
> > acl.*
> > FROM
> > pg_class,
> > aclexplode(relacl) AS acl
> > JOIN pg_roles ON acl.grantee = pg_roles.oid
> > WHERE
> > pg_roles.oid = 'some_role'::regrole;
> >
>
> Possible flaw in plan, the above only works with v12+.
>
>
>
> --
> Adrian Klaver
> adrian.klaver@aklaver.com
>
^ permalink raw reply [nested|flat] 11+ messages in thread
end of thread, other threads:[~2020-04-03 17:29 UTC | newest]
Thread overview: 11+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-04-03 03:34 Backing out of privilege grants rabbit hole AC Gomez <antklc@gmail.com>
2020-04-03 03:37 ` Guyren Howe <guyren@gmail.com>
2020-04-03 03:41 ` Guyren Howe <guyren@gmail.com>
2020-04-03 03:42 ` AC Gomez <antklc@gmail.com>
2020-04-03 04:57 ` raf <raf@raf.org>
2020-04-03 04:59 ` AC Gomez <antklc@gmail.com>
2020-04-03 08:50 ` Laurenz Albe <laurenz.albe@cybertec.at>
2020-04-03 13:55 ` Rob Sargent <robjsargent@gmail.com>
2020-04-03 17:18 ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-04-03 17:23 ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-04-03 17:29 ` AC Gomez <antklc@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox