From d5fb73bf9bfce9707befd5895d08f8c10eb5bc4a Mon Sep 17 00:00:00 2001 From: Laurence Isla Date: Tue, 30 Nov 2021 16:09:21 -0500 Subject: [PATCH] Fix GUC names using the old syntax --- api.rst | 2 +- auth.rst | 2 +- tutorials/tut1.rst | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api.rst b/api.rst index eb79826ab..f5d5f796d 100644 --- a/api.rst +++ b/api.rst @@ -2523,7 +2523,7 @@ As an example, let's add some cache headers for all requests that come from an I create or replace function custom_headers() returns void as $$ declare - user_agent text := current_setting('request.header.user-agent', true); + user_agent text := current_setting('request.headers', true)::json->>'user-agent'; begin if user_agent similar to '%MSIE (6.0|7.0)%' then perform set_config('response.headers', diff --git a/auth.rst b/auth.rst index 0c8c50726..cb2928e8c 100644 --- a/auth.rst +++ b/auth.rst @@ -95,7 +95,7 @@ SQL code can access claims through GUC variables set by PostgREST per request. F .. code:: sql - current_setting('request.jwt.claim.email', true) + current_setting('request.jwt.claims', true)::json->>'email'; 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. diff --git a/tutorials/tut1.rst b/tutorials/tut1.rst index fa89591f3..ec288fc97 100644 --- a/tutorials/tut1.rst +++ b/tutorials/tut1.rst @@ -212,7 +212,7 @@ First make a new schema and add the function: language plpgsql as $$ begin - if current_setting('request.jwt.claim.email', true) = + if current_setting('request.jwt.claims', true)::json->>'email' = 'disgruntled@mycompany.com' then raise insufficient_privilege using hint = 'Nope, we are on to you';