From b7d4d64fee2546d5db0988018767859381990af1 Mon Sep 17 00:00:00 2001 From: Wen Bo Xie <5532241+w3b6x9@users.noreply.github.com> Date: Mon, 8 Jul 2024 18:23:03 -0400 Subject: [PATCH] fix: update Realtime AuthZ policies in docs/demo (#27863) --- .../content/guides/realtime/authorization.mdx | 48 +++++++++---------- .../nextjs-authorization-demo/README.md | 4 +- 2 files changed, 26 insertions(+), 26 deletions(-) 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') )