MyGit

0.21.11.30

supabase/supabase

版本发布时间: 2021-11-30 18:06:54

supabase/supabase最新发布版本:1.24.08(2024-09-17 03:37:55)

System updates

All projects

New projects

Manual Changes Required

Update custom auth functions

Details

The PostgREST release notes document some changes to the way GUC variables are handled here.

Supabase has created a config flag in the Dashboard to ensure that this will not be a breaking change. These changes are required before you can upgrade to PostgreSQL 14+, or use Realtime RLS.

Supabase has already updated all the default auth functions (auth.uid(), auth.role() and auth.email()), however we have no way of updating functions which we have not written ourselves.

Affected

Unaffected

How to update

You need to update all functions that are using the legacy GUC naming convention (current_setting('request.jwt.claims.XXX', true)) to use the new convention (current_setting('request.jwt.claims', true)::json->>'XXX').

After you have made this change, you can safely

Example

For example, Supabase rewrote the auth.role() functions like this, to handle both legacy and new:

-- PREVIOUSLY
create or replace function auth.role() 
returns text 
language sql stable
as $$
  select current_setting('request.jwt.claim.role', true)::text;
$$;

-- UPDATED FUNCTION TO HANDLE NEW GUC NAMING SCHEME
create or replace function auth.role() 
returns text 
language sql stable
as $$
  select 
  	coalesce(
		current_setting('request.jwt.claim.role', true),
		(current_setting('request.jwt.claims', true)::jsonb ->> 'role')
	)::text
$$;

相关地址:原始地址 下载(tar) 下载(zip)

查看:2021-11-30发行的版本