Improving security

So far, you have seen that data is streamed as a superuser. However, it is not a good idea to allow super access from a remote side. Fortunately, PostgreSQL allows you to create a user that is only allowed to consume the transaction log stream but cannot do anything else.

Creating a user just for streaming is easy:

test=# CREATE USER repl LOGIN REPLICATION;CREATE ROLE

By assigning replication to the user, it is possible to use it just for streaming—everything else is forbidden.

It is highly recommended to not use your superuser account to set up streaming. Simply change the recovery.conf file to the newly created user. Not exposing superuser accounts will dramatically improve security (just like giving the replication user ...

Get Mastering PostgreSQL 10 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.