Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Never provide authorization from a client application, which is run on uncontrolled environment. And every device, that a user has physical access to, is an uncontrolled environment. This is security through obscurity &mdash; a user can simply use a debugger to get a database access credentials from client program memory and just use <code>psql</code> to do anything.</p> <p>Use roles.</p> <p>When I was developing an C++/PostgreSQL desktop application I've chosen to disallow all users access to modify all tables and I've created an API using Pl/PgSQL functions with <code>VOLATILE SECURITY DEFINER</code> options. But I think it wasn't a best approach, as it's not natural and error prone to use for example:</p> <pre><code>select add_person(?,?,?,?,?,?,?,?,?,?,?,?); </code></pre> <p>I think a better way would be to allow modifications to tables which a user needs to modify and, when needed, enforce authorization using BEFORE triggers, which would throw an error when current_user does not belong to a proper role.</p> <p>But <a href="http://www.postgresql.org/docs/current/static/sql-createfunction.html#SQL-CREATEFUNCTION-SECURITY" rel="nofollow">remember to use <code>set search_path=...</code> option in all functions that have anything to do with security</a>.</p> <hr> <p>If you want to authorize read-only access to some tables then it gets even more complicated. Either you'd need to disable select privilege for these tables and create API using security definer functions for accessing all data. This would be a monster size API, extremely ugly and extremely fragile. Or you'd need to disable select privilege for these tables and create views for them using <code>create view with (security_barrier)</code>. Also not pretty.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload