Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Update configuration page #483

Merged
merged 1 commit into from
Jan 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion admin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ First, create postgrest configuration in ``/etc/postgrest/config``
.. code-block:: ini

db-uri = "postgres://<your_user>:<your_password>@localhost:5432/<your_db>"
db-schema = "<your_exposed_schema>"
db-schemas = "<your_exposed_schema>"
db-anon-role = "<your_anon_role>"
db-pool = 10

Expand Down
14 changes: 7 additions & 7 deletions api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ As mentioned, computed columns do not appear in the output by default. However y

.. important::

Computed columns must be created under the :ref:`exposed schema <db-schema>` to be used in this way.
Computed columns must be created under the :ref:`exposed schema <db-schemas>` to be used in this way.

Unicode support
---------------
Expand Down Expand Up @@ -666,9 +666,9 @@ In general, when having smaller row-counts, the estimated count should be as clo

To help with these cases, PostgREST can get the exact count up until a threshold and get the planned count when
that threshold is surpassed. To use this behavior, you can specify the ``Prefer: count=estimated`` header. The **threshold** is
defined by :ref:`max-rows`.
defined by :ref:`db-max-rows`.

Here's an example. Suppose we set ``max-rows=1000`` and ``smalltable`` has 321 rows, then we'll get the exact count:
Here's an example. Suppose we set ``db-max-rows=1000`` and ``smalltable`` has 321 rows, then we'll get the exact count:

.. tabs::

Expand Down Expand Up @@ -1156,7 +1156,7 @@ It's also possible to embed `Materialized Views <https://www.postgresql.org/docs
Embedding Chains of Views
-------------------------

Views can also depend on other views, which in turn depend on the actual source table. For PostgREST to pick up those chains recursively to any depth, all the views must be in the search path, so either in the exposed schema (:ref:`db-schema`) or in one of the schemas set in :ref:`db-extra-search-path`. This does not apply to the source table, which could be in a private schema as well. See :ref:`schema_isolation` for more details.
Views can also depend on other views, which in turn depend on the actual source table. For PostgREST to pick up those chains recursively to any depth, all the views must be in the search path, so either in the exposed schema (:ref:`db-schemas`) or in one of the schemas set in :ref:`db-extra-search-path`. This does not apply to the source table, which could be in a private schema as well. See :ref:`schema_isolation` for more details.

.. _s_proc_embed:

Expand Down Expand Up @@ -2399,7 +2399,7 @@ PostgREST sets highly permissive cross origin resource sharing, that is why it a
Switching Schemas
=================

You can switch schemas at runtime with the ``Accept-Profile`` and ``Content-Profile`` headers. You can only switch to a schema that is included in :ref:`db-schema`.
You can switch schemas at runtime with the ``Accept-Profile`` and ``Content-Profile`` headers. You can only switch to a schema that is included in :ref:`db-schemas`.

For GET or HEAD, the schema to be used can be selected through the ``Accept-Profile`` header:

Expand Down Expand Up @@ -2516,7 +2516,7 @@ Notice that the variable should be set to an *array* of single-key objects rathe
Setting headers via pre-request
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

By using a :ref:`pre-request` function, you can add headers to GET/POST/PATCH/PUT/DELETE responses.
By using a :ref:`db-pre-request` function, you can add headers to GET/POST/PATCH/PUT/DELETE responses.
As an example, let's add some cache headers for all requests that come from an Internet Explorer(6 or 7) browser.

.. code-block:: postgresql
Expand All @@ -2532,7 +2532,7 @@ As an example, let's add some cache headers for all requests that come from an I
end; $$ language plpgsql;

-- set this function on postgrest.conf
-- pre-request = custom_headers
-- db-pre-request = custom_headers

Now when you make a GET request to a table or view, you'll get the cache headers.

Expand Down
6 changes: 3 additions & 3 deletions auth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ You can mix the group and individual role policies. For instance we could still
Custom Validation
-----------------

PostgREST honors the :code:`exp` claim for token expiration, rejecting expired tokens. However it does not enforce any extra constraints. An example of an extra constraint would be to immediately revoke access for a certain user. The configuration file parameter :code:`pre-request` specifies a stored procedure to call immediately after the authenticator switches into a new role and before the main query itself runs.
PostgREST honors the :code:`exp` claim for token expiration, rejecting expired tokens. However it does not enforce any extra constraints. An example of an extra constraint would be to immediately revoke access for a certain user. The configuration file parameter :code:`db-pre-request` specifies a stored procedure to call immediately after the authenticator switches into a new role and before the main query itself runs.

Here's an example. In the config file specify a stored procedure:

.. code:: ini

pre-request = "public.check_user"
db-pre-request = "public.check_user"

In the function you can run arbitrary code to check the request and raise an exception to block it if desired.

Expand Down Expand Up @@ -226,7 +226,7 @@ To use Auth0, create `an application <https://auth0.com/docs/get-started/applica
function (user, context, callback) {

// Follow the documentations at
// https://postgrest.org/en/latest/configuration.html#role-claim-key
// https://postgrest.org/en/latest/configuration.html#db-role-claim-key
// to set a custom role claim on PostgREST
// and use it as custom claim attribute in this rule
const myRoleClaim = 'https://myapp.com/role';
Expand Down
Loading