Fix #145, add authenticator role to tutorials
This commit is contained in:
committed by
Steve Chávez
parent
a163828c6c
commit
ff74567473
+9
-2
@@ -144,13 +144,20 @@ Next make a role to use for anonymous web requests. When a request comes in, Pos
|
|||||||
.. code-block:: postgres
|
.. code-block:: postgres
|
||||||
|
|
||||||
create role web_anon nologin;
|
create role web_anon nologin;
|
||||||
grant web_anon to postgres;
|
|
||||||
|
|
||||||
grant usage on schema api to web_anon;
|
grant usage on schema api to web_anon;
|
||||||
grant select on api.todos to web_anon;
|
grant select on api.todos to web_anon;
|
||||||
|
|
||||||
The :code:`web_anon` role has permission to access things in the :code:`api` schema, and to read rows in the :code:`todos` table.
|
The :code:`web_anon` role has permission to access things in the :code:`api` schema, and to read rows in the :code:`todos` table.
|
||||||
|
|
||||||
|
It's a good practice to create a dedicated role for connecting to the database, instead of using the highly privileged ``postgres`` role. So we'll do that, name the role ``authenticator`` and also grant him the ability to switch to the ``web_anon`` role :
|
||||||
|
|
||||||
|
.. code-block:: postgres
|
||||||
|
|
||||||
|
create role authenticator noinherit login password 'mysecretpassword';
|
||||||
|
grant web_anon to authenticator;
|
||||||
|
|
||||||
|
|
||||||
Now quit out of psql; it's time to start the API!
|
Now quit out of psql; it's time to start the API!
|
||||||
|
|
||||||
.. code-block:: psql
|
.. code-block:: psql
|
||||||
@@ -164,7 +171,7 @@ PostgREST uses a configuration file to tell it how to connect to the database. C
|
|||||||
|
|
||||||
.. code-block:: ini
|
.. code-block:: ini
|
||||||
|
|
||||||
db-uri = "postgres://postgres:mysecretpassword@localhost/postgres"
|
db-uri = "postgres://authenticator:mysecretpassword@localhost/postgres"
|
||||||
db-schema = "api"
|
db-schema = "api"
|
||||||
db-anon-role = "web_anon"
|
db-anon-role = "web_anon"
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ The previous tutorial created a :code:`web_anon` role in the database with which
|
|||||||
-- in the previous tutorial
|
-- in the previous tutorial
|
||||||
|
|
||||||
create role todo_user nologin;
|
create role todo_user nologin;
|
||||||
grant todo_user to postgres;
|
grant todo_user to authenticator;
|
||||||
|
|
||||||
grant usage on schema api to todo_user;
|
grant usage on schema api to todo_user;
|
||||||
grant all on api.todos to todo_user;
|
grant all on api.todos to todo_user;
|
||||||
|
|||||||
Reference in New Issue
Block a user