pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephen Frost <sfrost@snowman.net>
To: Siegfried Bilstein <sbilstein@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Thoughts on row-level security for webapps?
Date: Thu, 3 Jan 2019 15:49:53 -0500
Message-ID: <20190103204953.GW2528@tamriel.snowman.net> (raw)
In-Reply-To: <CAOd5ZkpQw7OG=bezbF9HDaM_TnSx=PHWGmmdZsL_XXbGKt_qmQ@mail.gmail.com>
References: <CAOd5ZkpQw7OG=bezbF9HDaM_TnSx=PHWGmmdZsL_XXbGKt_qmQ@mail.gmail.com>

Greetings,

* Siegfried Bilstein (sbilstein@gmail.com) wrote:
> I'm evaluating using a tool called Postgraphile that generates a GraphSQL
> server from a postgres setup. The recommended way of handling security is
> to implement RLS within postgres and simply have the webserver take a
> cookie or similar and define which user is querying data.
> 
> I've normally built webapps like this: pull out user id from a session
> cookie -> the API endpoint verifies the user and whether or not it has
> access to the given data -> app code mutates the data.
> 
> With Postgraphile the request specifies the mutation and the server
> processes the request and relies on Postgres to determine if the user has
> correct access rights.
> 
> It seems like I would need to create a ROLE for every single member that
> signs up for my website which I'm a little concerned about. Is this a
> common usage pattern for SQL security? Any gotchas relying on RLS?

You don't have to create a role for every member, though depending on
your expectation you might want to.  You could just set a custom GUC
which is used in the policy, but you then have to trust the web
application code to always do that correctly and to always properly
validate the client (without bugs, of course).

RLS has been around for a while now and it works really rather well in
most cases.  There are some corner cases where you're doing some kind of
filtering that might be able to use an index but the functions aren't
leakproof and therefore can't be used, causing a performance regression,
but that's not too hard to test for and only an issue if the policy
itself isn't very selective.

Thanks!

Stephen

Attachments:

  signature.asc (application/pgp-signature, 818B) download

view thread (5+ messages)  latest in thread

Message-ID: <20190103204953.GW2528@tamriel.snowman.net>
Permalink:  ../20190103204953.GW2528@tamriel.snowman.net/
Also on:    postgresql.org/message-id/20190103204953.GW2528@tamriel.snowman.net

 · 

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: sfrost@snowman.net, sbilstein@gmail.com
  Subject: Re: Thoughts on row-level security for webapps?
  In-Reply-To: <20190103204953.GW2528@tamriel.snowman.net>
  References: <CAOd5ZkpQw7OG=bezbF9HDaM_TnSx=PHWGmmdZsL_XXbGKt_qmQ@mail.gmail.com> <20190103204953.GW2528@tamriel.snowman.net>

* 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