Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: update Realtime AuthZ policies in docs/demo (#27863)

Wen Bo Xieb7d4d64fee25
diff --git a/apps/docs/content/guides/realtime/authorization.mdx b/apps/docs/content/guides/realtime/authorization.mdx
index 17f4d6862e1..791435a8166 100644
--- a/apps/docs/content/guides/realtime/authorization.mdx
+++ b/apps/docs/content/guides/realtime/authorization.mdx
@@ -110,12 +110,12 @@ to authenticated
using (
exists (
select
- ru.user_id
+ user_id
from
- rooms_users ru
+ rooms_users
where
- ru.user_id = (select auth.uid())
- and ru.topic = (select realtime.topic())
+ user_id = (select auth.uid())
+ and topic = (select realtime.topic())
and realtime.messages.extension in ('broadcast')
)
);
@@ -159,12 +159,12 @@ to authenticated
with check (
exists (
select
- ru.user_id
+ user_id
from
- rooms_users ru
+ rooms_users
where
- ru.user_id = (select auth.uid())
- and ru.topic = (select realtime.topic())
+ user_id = (select auth.uid())
+ and topic = (select realtime.topic())
and realtime.messages.extension in ('broadcast')
)
);
@@ -186,12 +186,12 @@ to authenticated
using (
exists (
select
- ru.user_id
+ user_id
from
- rooms_users ru
+ rooms_users
where
- ru.user_id = (select auth.uid())
- and ru.topic = (select realtime.topic())
+ user_id = (select auth.uid())
+ and topic = (select realtime.topic())
and realtime.messages.extension in ('presence')
)
);
@@ -209,12 +209,12 @@ to authenticated
with check (
exists (
select
- ru.user_id
+ user_id
from
- rooms_users ru
+ rooms_users
where
- ru.user_id = (select auth.uid())
- and ru.name = (select realtime.topic())
+ user_id = (select auth.uid())
+ and name = (select realtime.topic())
and realtime.messages.extension in ('presence')
)
);
@@ -236,12 +236,12 @@ to authenticated
using (
exists (
select
- ru.user_id
+ user_id
from
- rooms_users ru
+ rooms_users
where
- ru.user_id = (select auth.uid())
- and ru.topic = (select realtime.topic())
+ user_id = (select auth.uid())
+ and topic = (select realtime.topic())
and realtime.messages.extension in ('broadcast', 'presence')
)
);
@@ -259,12 +259,12 @@ to authenticated
with check (
exists (
select
- ru.user_id
+ user_id
from
- rooms_users ru
+ rooms_users
where
- ru.user_id = (select auth.uid())
- and ru.name = (select realtime.topic())
+ user_id = (select auth.uid())
+ and name = (select realtime.topic())
and realtime.messages.extension in ('broadcast', 'presence')
)
);
diff --git a/examples/realtime/nextjs-authorization-demo/README.md b/examples/realtime/nextjs-authorization-demo/README.md
index 932fa955ea7..fdb99441700 100644
--- a/examples/realtime/nextjs-authorization-demo/README.md
+++ b/examples/realtime/nextjs-authorization-demo/README.md
@@ -112,7 +112,7 @@ USING (
EXISTS (
SELECT 1
FROM public.rooms_users
- WHERE user_id = auth.uid()
+ WHERE user_id = (select auth.uid())
AND room_topic = realtime.topic()
AND realtime.messages.extension in ('broadcast', 'presence')
)
@@ -126,7 +126,7 @@ WITH CHECK (
EXISTS (
SELECT 1
FROM public.rooms_users
- WHERE user_id = auth.uid()
+ WHERE user_id = (select auth.uid())
AND room_topic = realtime.topic()
AND realtime.messages.extension in ('broadcast', 'presence')
)