From fbe317b2444ef0ae0a0b550906b27537bc2394c1 Mon Sep 17 00:00:00 2001 From: Adam Kliment <79609+netmilk@users.noreply.github.com> Date: Tue, 22 Feb 2022 17:48:22 +0100 Subject: [PATCH] Update auth.rst (#507) --- docs/auth.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/auth.rst b/docs/auth.rst index 867339cbc..94e449db5 100644 --- a/docs/auth.rst +++ b/docs/auth.rst @@ -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.