Re: Postgres 12 RLS - Mailing list pgsql-general

From Paul Förster
Subject Re: Postgres 12 RLS
Date
Msg-id 7C76B67D-AF49-4499-B896-85DA40FCC8B1@gmail.com
Whole thread Raw
In response to Re: Postgres 12 RLS  (Laura Smith <n5d9xq3ti233xiyif2vp@protonmail.ch>)
Responses Re: Postgres 12 RLS  (Laura Smith <n5d9xq3ti233xiyif2vp@protonmail.ch>)
List pgsql-general
Hi Laura,

> On 08. Jun, 2020, at 12:46, Laura Smith <n5d9xq3ti233xiyif2vp@protonmail.ch> I had a lightbulb moment just now and
triedthat, but it doesn't seem to be working. 
>
> The app returns "pg_execute(): Query failed: ERROR:  permission denied for table...."
>
> This is despite me:
> • Changing to SECURITY INVOKER on the PG function.
> • Granting the app user relevant perms on the underlying table
> • Re-granting execute for the app on the function
>
> Am I missing somehthing ?

another possibility maybe is to use session_user instead of current_user in your policy.

current_user    name    user name of current execution context
session_user    name    session user name

The latter is the name of the user who actually started the session. So it should be myappuser in your case.

https://www.postgresql.org/docs/current/functions-info.html

Cheers,
Paul


pgsql-general by date:

Previous
From: Alastair McKinley
Date:
Subject: ts_debug() style functions for jsonpath debugging
Next
From: Laura Smith
Date:
Subject: Re: Postgres 12 RLS