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

Commit

Permalink
Update auth.rst (#507)
Browse files Browse the repository at this point in the history
  • Loading branch information
netmilk authored Feb 22, 2022
1 parent abe0daa commit fbe317b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/auth.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,18 @@ Alternately database roles can represent groups instead of (or in addition to) i
SQL code can access claims through GUC variables set by PostgREST per request. For instance to get the email claim, call this function:

For PostgreSQL server version >= 14

.. code:: sql
current_setting('request.jwt.claims', true)::json->>'email';
For PostgreSQL server version < 14

.. code:: sql
current_setting('request.jwt.claim.email', true);
This allows JWT generation services to include extra information and your database code to react to it. For instance the RLS example could be modified to use this current_setting rather than current_user. The second 'true' argument tells current_setting to return NULL if the setting is missing from the current configuration.

Expand Down

0 comments on commit fbe317b

Please sign in to comment.