From: raf <raf@raf.org>
To: pgsql-general@lists.postgresql.org
Subject: Re: Changing from security definer to security invoker without dropping ?
Date: Sat, 13 Jun 2020 08:56:48 +1000
Message-ID: <20200612225648.4hbpvyf5w2j3m36a@raf.org> (raw)
In-Reply-To: <PbdhttIUMTxHPxoJrd2ceE9iOxIOSptIK0tLo_9KcZQZiJeyoPW5_uFz794Kh56vEt1h9CPIk66FLdj0HiZIN8REzWfGoqeE42gZbO_ecCU=@protonmail.ch>
References: <JjNNVyex4-kOUrDx5hV-MXEgWxlT7cYmCN8DheQuJGPsA0p24kkqVGMUoqrNIDa1b5Zo2uC9LCvtmX_NWg23NmGIa3bJyga6lJTJ6gCnSOM=@protonmail.ch>
<CAFj8pRCgH6HnqchEuS0LCtYQk+ZqtrB8nAXT8OvUXzf_8BmbKw@mail.gmail.com>
<PbdhttIUMTxHPxoJrd2ceE9iOxIOSptIK0tLo_9KcZQZiJeyoPW5_uFz794Kh56vEt1h9CPIk66FLdj0HiZIN8REzWfGoqeE42gZbO_ecCU=@protonmail.ch>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: raf@raf.org
Subject: Re: Changing from security definer to security invoker without dropping ?
In-Reply-To: <20200612225648.4hbpvyf5w2j3m36a@raf.org>
References: <JjNNVyex4-kOUrDx5hV-MXEgWxlT7cYmCN8DheQuJGPsA0p24kkqVGMUoqrNIDa1b5Zo2uC9LCvtmX_NWg23NmGIa3bJyga6lJTJ6gCnSOM=@protonmail.ch> <CAFj8pRCgH6HnqchEuS0LCtYQk+ZqtrB8nAXT8OvUXzf_8BmbKw@mail.gmail.com> <PbdhttIUMTxHPxoJrd2ceE9iOxIOSptIK0tLo_9KcZQZiJeyoPW5_uFz794Kh56vEt1h9CPIk66FLdj0HiZIN8REzWfGoqeE42gZbO_ecCU=@protonmail.ch> <20200612225648.4hbpvyf5w2j3m36a@raf.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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