Update auth.rst (#507)

This commit is contained in:
Adam Kliment
2022-02-22 11:48:22 -05:00
committed by GitHub
parent abe0daa3dc
commit fbe317b244
+9
View File
@@ -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: 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 .. code:: sql
current_setting('request.jwt.claims', true)::json->>'email'; 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. 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.