Re: Web users as database users? - Mailing list pgsql-general

From Andrei Zhidenkov
Subject Re: Web users as database users?
Date
Msg-id D8BCF6CD-3C3B-4F66-A26F-17483A80C76C@n26.com
Whole thread Raw
In response to Re: Web users as database users?  (Michael Lewis <mlewis@entrata.com>)
List pgsql-general
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> 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?

pgsql-general by date:

Previous
From: Michael Lewis
Date:
Subject: Re: Web users as database users?
Next
From: Torsten Krah
Date:
Subject: Re: Force WAL cleanup on running instance