From 7742891c26f14919b51a1c041b652bd75ab3008e Mon Sep 17 00:00:00 2001 From: Joe Nelson Date: Mon, 6 Feb 2017 10:56:41 -0800 Subject: [PATCH] safeupdate via PGXN --- admin.rst | 9 ++++++++- intro.rst | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/admin.rst b/admin.rst index 24ce3df23..d157fc4d9 100644 --- a/admin.rst +++ b/admin.rst @@ -130,7 +130,14 @@ However it's very easy to delete the **entire table** by omitting the query para DELETE /logs HTTP/1.1 -This can happen accidentally such as by switching a request from a GET to a DELETE. To protect against accidental operations use the `pg-safeupdate `_ PostgreSQL extension. It raises an error if UPDATE or DELETE are executed without specifying conditions. +This can happen accidentally such as by switching a request from a GET to a DELETE. To protect against accidental operations use the `pg-safeupdate `_ PostgreSQL extension. It raises an error if UPDATE or DELETE are executed without specifying conditions. To install it you can use the `PGXN `_ network: + +.. code-block:: bash + + sudo -E pgxn install safeupdate + + # then add this to postgresql.conf: + # shared_preload_libraries='safeupdate'; This does not protect against malicious actions, since someone can add a url parameter that does not affect the result set. To prevent this you must turn to database permissions, forbidding the wrong people from deleting rows, and using `row-level security `_ if finer access control is required. diff --git a/intro.rst b/intro.rst index 6d94d44da..b87681d72 100644 --- a/intro.rst +++ b/intro.rst @@ -93,6 +93,7 @@ Extensions * `srid/spas `_ - allow file uploads and basic auth * `svmnotn/postgrest-auth `_ - OAuth2-inspired external auth server * `nblumoe/postgrest-oauth `_ - OAuth2 WAI middleware +* `pg-safeupdate `_ - Prevent full-table updates or deletes Commercial PaaS ---------------