pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedChanging from security definer to security invoker without dropping ?
5+ messages / 3 participants
[nested] [flat]
* Changing from security definer to security invoker without dropping ?
@ 2020-06-11 07:29 Laura Smith <n5d9xq3ti233xiyif2vp@protonmail.ch>
2020-06-11 07:39 ` Re: Changing from security definer to security invoker without dropping ? Pavel Stehule <pavel.stehule@gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Laura Smith @ 2020-06-11 07:29 UTC (permalink / raw)
To: postgre <pgsql-general@lists.postgresql.org>
Hi,
Just curious if there is a way to switch a function from definer to invoker without dropping ?
We're working on improving the security posture by changing functions from definer to invoker, but I'm wondering what the best way to roll this out to production is given that dropping and re-creating functions could potentially cause upstream client hassles ?
Laura
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Changing from security definer to security invoker without dropping ?
2020-06-11 07:29 Changing from security definer to security invoker without dropping ? Laura Smith <n5d9xq3ti233xiyif2vp@protonmail.ch>
@ 2020-06-11 07:39 ` Pavel Stehule <pavel.stehule@gmail.com>
2020-06-11 07:51 ` Re: Changing from security definer to security invoker without dropping ? Laura Smith <n5d9xq3ti233xiyif2vp@protonmail.ch>
0 siblings, 1 reply; 5+ messages in thread
From: Pavel Stehule @ 2020-06-11 07:39 UTC (permalink / raw)
To: Laura Smith <n5d9xq3ti233xiyif2vp@protonmail.ch>; +Cc: postgre <pgsql-general@lists.postgresql.org>
Hi
čt 11. 6. 2020 v 9:29 odesílatel Laura Smith <
n5d9xq3ti233xiyif2vp@protonmail.ch> napsal:
> Hi,
>
> Just curious if there is a way to switch a function from definer to
> invoker without dropping ?
>
create function foo(a int) returns int as $$ begin return $1; end $$
language plpgsql;
postgres=# alter function foo (int) security definer;
ALTER FUNCTION
postgres=# alter function foo (int) security invoker;
ALTER FUNCTION
regards
Pavel
>
> We're working on improving the security posture by changing functions from
> definer to invoker, but I'm wondering what the best way to roll this out to
> production is given that dropping and re-creating functions could
> potentially cause upstream client hassles ?
>
> Laura
>
>
>
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Changing from security definer to security invoker without dropping ?
2020-06-11 07:29 Changing from security definer to security invoker without dropping ? Laura Smith <n5d9xq3ti233xiyif2vp@protonmail.ch>
2020-06-11 07:39 ` Re: Changing from security definer to security invoker without dropping ? Pavel Stehule <pavel.stehule@gmail.com>
@ 2020-06-11 07:51 ` Laura Smith <n5d9xq3ti233xiyif2vp@protonmail.ch>
2020-06-11 07:55 ` Re: Changing from security definer to security invoker without dropping ? Pavel Stehule <pavel.stehule@gmail.com>
2020-06-12 22:56 ` Re: Changing from security definer to security invoker without dropping ? raf <raf@raf.org>
0 siblings, 2 replies; 5+ messages in thread
From: Laura Smith @ 2020-06-11 07:51 UTC (permalink / raw)
To: Pavel Stehule <pavel.stehule@gmail.com>; +Cc: postgre <pgsql-general@lists.postgresql.org>
Sent with ProtonMail Secure Email.
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Thursday, 11 June 2020 08:39, Pavel Stehule <pavel.stehule@gmail.com> wrote:
> Hi
>
> čt 11. 6. 2020 v 9:29 odesílatel Laura Smith <n5d9xq3ti233xiyif2vp@protonmail.ch> napsal:
>
> > Hi,
> >
> > Just curious if there is a way to switch a function from definer to invoker without dropping ?
>
> create function foo(a int) returns int as $$ begin return $1; end $$ language plpgsql;
>
> postgres=# alter function foo (int) security definer;
> ALTER FUNCTION
> postgres=# alter function foo (int) security invoker;
> ALTER FUNCTION
>
> regards
>
> Pavel
Thanks Pavel ! Didn't realise it was that easy.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Changing from security definer to security invoker without dropping ?
2020-06-11 07:29 Changing from security definer to security invoker without dropping ? Laura Smith <n5d9xq3ti233xiyif2vp@protonmail.ch>
2020-06-11 07:39 ` Re: Changing from security definer to security invoker without dropping ? Pavel Stehule <pavel.stehule@gmail.com>
2020-06-11 07:51 ` Re: Changing from security definer to security invoker without dropping ? Laura Smith <n5d9xq3ti233xiyif2vp@protonmail.ch>
@ 2020-06-11 07:55 ` Pavel Stehule <pavel.stehule@gmail.com>
1 sibling, 0 replies; 5+ messages in thread
From: Pavel Stehule @ 2020-06-11 07:55 UTC (permalink / raw)
To: Laura Smith <n5d9xq3ti233xiyif2vp@protonmail.ch>; +Cc: postgre <pgsql-general@lists.postgresql.org>
čt 11. 6. 2020 v 9:51 odesílatel Laura Smith <
n5d9xq3ti233xiyif2vp@protonmail.ch> napsal:
>
>
>
> Sent with ProtonMail <https://protonmail.com; Secure Email.
>
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Thursday, 11 June 2020 08:39, Pavel Stehule <pavel.stehule@gmail.com>
> wrote:
>
> Hi
>
> čt 11. 6. 2020 v 9:29 odesílatel Laura Smith <
> n5d9xq3ti233xiyif2vp@protonmail.ch> napsal:
>
>> Hi,
>>
>> Just curious if there is a way to switch a function from definer to
>> invoker without dropping ?
>>
>
> create function foo(a int) returns int as $$ begin return $1; end $$
> language plpgsql;
>
> postgres=# alter function foo (int) security definer;
> ALTER FUNCTION
> postgres=# alter function foo (int) security invoker;
> ALTER FUNCTION
>
> regards
>
> Pavel
>
>
> Thanks Pavel ! Didn't realise it was that easy.
>
It is postgres - things are easy (almost time) or impossible :)
Pavel
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Changing from security definer to security invoker without dropping ?
2020-06-11 07:29 Changing from security definer to security invoker without dropping ? Laura Smith <n5d9xq3ti233xiyif2vp@protonmail.ch>
2020-06-11 07:39 ` Re: Changing from security definer to security invoker without dropping ? Pavel Stehule <pavel.stehule@gmail.com>
2020-06-11 07:51 ` Re: Changing from security definer to security invoker without dropping ? Laura Smith <n5d9xq3ti233xiyif2vp@protonmail.ch>
@ 2020-06-12 22:56 ` raf <raf@raf.org>
1 sibling, 0 replies; 5+ messages in thread
From: raf @ 2020-06-12 22:56 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Laura Smith wrote:
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Thursday, 11 June 2020 08:39, Pavel Stehule <pavel.stehule@gmail.com> wrote:
>
> > Hi
> >
> > čt 11. 6. 2020 v 9:29 odesílatel Laura Smith <n5d9xq3ti233xiyif2vp@protonmail.ch> napsal:
> >
> > > Hi,
> > >
> > > Just curious if there is a way to switch a function from definer to invoker without dropping ?
> >
> > create function foo(a int) returns int as $$ begin return $1; end $$ language plpgsql;
> >
> > postgres=# alter function foo (int) security definer;
> > ALTER FUNCTION
> > postgres=# alter function foo (int) security invoker;
> > ALTER FUNCTION
> >
> > regards
> >
> > Pavel
>
> Thanks Pavel ! Didn't realise it was that easy.
"create or replace function..." with "security invoker"
(or without "security definer" since security invoker
is the default) is probably another way to do it, but
it would be slower than "alter function" since it needs
to parse the code again. That might matter if you have
many functions to change.
Bear in mind that things might break with such a change.
There might be a reason that the functions needed to be
created as security definers. I'd recommend checking
each function's need to be a security definer before
changing it (or just test it thoroughly somewhere).
cheers,
raf
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2020-06-12 22:56 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-06-11 07:29 Changing from security definer to security invoker without dropping ? Laura Smith <n5d9xq3ti233xiyif2vp@protonmail.ch>
2020-06-11 07:39 ` Pavel Stehule <pavel.stehule@gmail.com>
2020-06-11 07:51 ` Laura Smith <n5d9xq3ti233xiyif2vp@protonmail.ch>
2020-06-11 07:55 ` Pavel Stehule <pavel.stehule@gmail.com>
2020-06-12 22:56 ` raf <raf@raf.org>
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