pg.ddx.io pgsql-general@postgresql.org mailing list archivehelp / color / mirror / Atom feed
From: Andrei Zhidenkov <andrei.zhidenkov@n26.com>
To: Michael Lewis <mlewis@entrata.com>
To: tgl@sss.pgh.pa.us
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Web users as database users?
Date: Wed, 11 Mar 2020 16:00:57 +0100
Message-ID: <D8BCF6CD-3C3B-4F66-A26F-17483A80C76C@n26.com> (raw)
In-Reply-To: <CAHOFxGpS-_dGTCDkiBEE6M3AEkoSeLbrPTy8HM8kEEdHTktucA@mail.gmail.com>
References: <CAPjKuyVzvojzntx2MNMWEvuP3--z_8ZzDbdYrbvNmXkqUeLfhQ@mail.gmail.com>
<f5dbb11b-c041-cea6-766f-63c223c526f2@minerva.info>
<28CB89D3-194A-420F-868A-0AFC169EF7E5@gmail.com>
<16391.1568989132@sss.pgh.pa.us>
<CAHOFxGpS-_dGTCDkiBEE6M3AEkoSeLbrPTy8HM8kEEdHTktucA@mail.gmail.com>
I used to use a different approach:
1. Create auth() pl/python procedure as follows:
create or replace
function auth(auser_id integer) returns void as $$
GD['user_id'] = auser_id
$$ language plpythonu;
This procedure is supposed to be called after a sucesseful authorisation (in a database or on application side).
2. Create get_current_user() procedure:
create or replace
function get_current_user() returns integer as $$
return GD.get('user_id')
$$ language plpythonu stable security definer;
Now you can get current user id from every SQL query or stored procedure. It works fast because Python shared array GD is always present in memory.
> On 11. Mar 2020, at 15:46, Michael Lewis <mlewis@entrata.com> wrote:
>
> On Fri, Sep 20, 2019 at 8:19 AM Tom Lane <tgl@sss.pgh.pa.us <mailto:tgl@sss.pgh.pa.us>> wrote:
> There is a restriction on how many distinct GRANTs you can
> issue against any one object --- performance will get bad if the ACL
> list gets too large.
>
>
> Any ballpark numbers here? Are we talking 50 or 8000?
view thread (9+ messages) latest in thread
Message-ID: <D8BCF6CD-3C3B-4F66-A26F-17483A80C76C@n26.com> Permalink: ../D8BCF6CD-3C3B-4F66-A26F-17483A80C76C@n26.com/ Also on: postgresql.org/message-id/D8BCF6CD-3C3B-4F66-A26F-17483A80C76C@n26.com ·
reply
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: andrei.zhidenkov@n26.com, mlewis@entrata.com, tgl@sss.pgh.pa.us Subject: Re: Web users as database users? In-Reply-To: <D8BCF6CD-3C3B-4F66-A26F-17483A80C76C@n26.com> References: <CAPjKuyVzvojzntx2MNMWEvuP3--z_8ZzDbdYrbvNmXkqUeLfhQ@mail.gmail.com> <f5dbb11b-c041-cea6-766f-63c223c526f2@minerva.info> <28CB89D3-194A-420F-868A-0AFC169EF7E5@gmail.com> <16391.1568989132@sss.pgh.pa.us> <CAHOFxGpS-_dGTCDkiBEE6M3AEkoSeLbrPTy8HM8kEEdHTktucA@mail.gmail.com> <D8BCF6CD-3C3B-4F66-A26F-17483A80C76C@n26.com> * 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