Deprecated RLS features

Last edited: 1/21/2025

The auth.role() function is now deprecated

The auth.role() function has been deprecated in favour of using the TO field, natively supported within Postgres:


_13
-- DEPRECATED
_13
create policy "Public profiles are viewable by everyone."
_13
on profiles for select using (
_13
auth.role() = 'authenticated' or auth.role() = 'anon'
_13
);
_13
_13
-- RECOMMENDED
_13
create policy "Public profiles are viewable by everyone."
_13
on profiles for select
_13
to authenticated, anon
_13
using (
_13
true
_13
);

The auth.email() function is now deprecated

The auth.email() function has been deprecated in favour a more generic function to return the full JWT:


_11
- DEPRECATED
_11
create policy "User can view their profile."
_11
on profiles for select using (
_11
auth.email() = email
_11
);
_11
_11
-- RECOMMENDED
_11
create policy "User can view their profile."
_11
on profiles for select using (
_11
(auth.jwt() ->> 'email') = email
_11
);