pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Paul Förster <paul.foerster@gmail.com>
To: Laura Smith <n5d9xq3ti233xiyif2vp@protonmail.ch>
Cc: postgre <pgsql-general@lists.postgresql.org>
Subject: Re: Postgres 12 RLS
Date: Mon, 8 Jun 2020 13:42:50 +0200
Message-ID: <7C76B67D-AF49-4499-B896-85DA40FCC8B1@gmail.com> (raw)
In-Reply-To: <WllKePxJqsF7cRQpEMx5mazwFaxyHIXuJOro5q_Mtj0JqOHEpXib0BgLN9xrP9tGxS4PXvfFBbhSEkoFLovWsM4LveExPgYQ3Jf7KQggkNA=@protonmail.ch>
References: <HQQTmWw2GOI540iQNVYlo-Hdq7FXd-L1Iyq1g3SOen8t-jugIBcwQ1FCKngTRnZ4wwttn1z5mMLbQrS5aK_srLa6HKN6mFUOoiUDtS__y0I=@protonmail.ch>
	<B3750A95-C425-4C69-9D85-DAF5582FEA8B@gmail.com>
	<WllKePxJqsF7cRQpEMx5mazwFaxyHIXuJOro5q_Mtj0JqOHEpXib0BgLN9xrP9tGxS4PXvfFBbhSEkoFLovWsM4LveExPgYQ3Jf7KQggkNA=@protonmail.ch>

Hi Laura,

> On 08. Jun, 2020, at 12:46, Laura Smith <n5d9xq3ti233xiyif2vp@protonmail.ch> I had a lightbulb moment just now and tried that, 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




view thread (5+ messages)  latest in thread

Message-ID: <7C76B67D-AF49-4499-B896-85DA40FCC8B1@gmail.com>
Permalink:  ../7C76B67D-AF49-4499-B896-85DA40FCC8B1@gmail.com/
Also on:    postgresql.org/message-id/7C76B67D-AF49-4499-B896-85DA40FCC8B1@gmail.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: paul.foerster@gmail.com, n5d9xq3ti233xiyif2vp@protonmail.ch
  Subject: Re: Postgres 12 RLS
  In-Reply-To: <7C76B67D-AF49-4499-B896-85DA40FCC8B1@gmail.com>
  References: <HQQTmWw2GOI540iQNVYlo-Hdq7FXd-L1Iyq1g3SOen8t-jugIBcwQ1FCKngTRnZ4wwttn1z5mMLbQrS5aK_srLa6HKN6mFUOoiUDtS__y0I=@protonmail.ch> <B3750A95-C425-4C69-9D85-DAF5582FEA8B@gmail.com> <WllKePxJqsF7cRQpEMx5mazwFaxyHIXuJOro5q_Mtj0JqOHEpXib0BgLN9xrP9tGxS4PXvfFBbhSEkoFLovWsM4LveExPgYQ3Jf7KQggkNA=@protonmail.ch> <7C76B67D-AF49-4499-B896-85DA40FCC8B1@gmail.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