mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 09:25:06 +03:00
fix: update all examples and snippets to use select for auth rls func… (#22632)
fix: update all examples and snippets to use select for auth rls functions
This commit is contained in:
1 parent
b07f8304e0
commit
5d8cef6040
48 files changed
+151
-152
No files matched your search
@@ -35,7 +35,7 @@ create policy "Users can view private_posts if they have signed in via MFA"
|
||||
on public.private_posts
|
||||
for select
|
||||
to authenticated
|
||||
using (auth.jwt()->>'aal' = 'aal2');
|
||||
using ((select auth.jwt()->>'aal') = 'aal2');
|
||||
```
|
||||
|
||||
- Run the app and test the login flow 🚀
|
||||
|
||||
@@ -56,16 +56,16 @@ create table todos (
|
||||
alter table todos enable row level security;
|
||||
|
||||
create policy "Individuals can create todos." on todos for
|
||||
insert with check (auth.uid() = user_id);
|
||||
insert with check ((select auth.uid()) = user_id);
|
||||
|
||||
create policy "Individuals can view their own todos. " on todos for
|
||||
select using (auth.uid() = user_id);
|
||||
select using ((select auth.uid()) = user_id);
|
||||
|
||||
create policy "Individuals can update their own todos." on todos for
|
||||
update using (auth.uid() = user_id);
|
||||
update using ((select auth.uid()) = user_id);
|
||||
|
||||
create policy "Individuals can delete their own todos." on todos for
|
||||
delete using (auth.uid() = user_id);
|
||||
delete using ((select auth.uid()) = user_id);
|
||||
```
|
||||
|
||||
## Authors
|
||||
|
||||
@@ -47,16 +47,16 @@ create table todos (
|
||||
alter table todos enable row level security;
|
||||
|
||||
create policy "Individuals can create todos." on todos for
|
||||
insert with check (auth.uid() = user_id);
|
||||
insert with check ((select auth.uid()) = user_id);
|
||||
|
||||
create policy "Individuals can view their own todos. " on todos for
|
||||
select using (auth.uid() = user_id);
|
||||
select using ((select auth.uid()) = user_id);
|
||||
|
||||
create policy "Individuals can update their own todos." on todos for
|
||||
update using (auth.uid() = user_id);
|
||||
update using ((select auth.uid()) = user_id);
|
||||
|
||||
create policy "Individuals can delete their own todos." on todos for
|
||||
delete using (auth.uid() = user_id);
|
||||
delete using ((select auth.uid()) = user_id);
|
||||
```
|
||||
|
||||
## Authors
|
||||
|
||||
@@ -79,10 +79,10 @@ create policy "Public profiles are viewable by everyone."
|
||||
using ( true );
|
||||
create policy "Users can insert their own profile."
|
||||
on profiles for insert
|
||||
with check ( auth.uid() = id );
|
||||
with check ( (select auth.uid()) = id );
|
||||
create policy "Users can update own profile."
|
||||
on profiles for update
|
||||
using ( auth.uid() = id );
|
||||
using ( (select auth.uid()) = id );
|
||||
-- Set up Realtime!
|
||||
begin;
|
||||
drop publication if exists supabase_realtime;
|
||||
|
||||
@@ -82,11 +82,11 @@ select
|
||||
|
||||
create policy "Users can insert their own profile." on profiles for insert
|
||||
with
|
||||
check (auth.uid () = id);
|
||||
check ((select auth.uid()) = id);
|
||||
|
||||
create policy "Users can update own profile." on profiles for
|
||||
update
|
||||
using (auth.uid () = id);
|
||||
using ((select auth.uid()) = id);
|
||||
|
||||
-- Set up Realtime!
|
||||
begin;
|
||||
|
||||
@@ -52,11 +52,11 @@ create policy "Public profiles are viewable by everyone."
|
||||
|
||||
create policy "Users can insert their own profile."
|
||||
on profiles for insert
|
||||
with check ( auth.uid() = id );
|
||||
with check ( (select auth.uid()) = id );
|
||||
|
||||
create policy "Users can update own profile."
|
||||
on profiles for update
|
||||
using ( auth.uid() = id );
|
||||
using ( (select auth.uid()) = id );
|
||||
|
||||
-- Set up Realtime!
|
||||
begin;
|
||||
|
||||
@@ -92,10 +92,10 @@ create policy "Public profiles are viewable by everyone." on profiles
|
||||
for select using (true);
|
||||
|
||||
create policy "Users can insert their own profile." on profiles
|
||||
for insert with check (auth.uid() = id);
|
||||
for insert with check ((select auth.uid()) = id);
|
||||
|
||||
create policy "Users can update own profile." on profiles
|
||||
for update using (auth.uid() = id);
|
||||
for update using ((select auth.uid()) = id);
|
||||
|
||||
-- This trigger automatically creates a profile entry when a new user signs up via Supabase Auth.
|
||||
-- See https://supabase.com/docs/guides/auth/managing-user-data#using-triggers for more details.
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
# Supabase Nuxt User Management
|
||||
|
||||
This repo is a quick sample of how you can get started building apps using Nuxt 3 and Supabase. You can find a step by step guide of how to build out this app in the [Quickstart: Nuxt guide](https://supabase.io/docs/guides/with-nuxt-3).
|
||||
This repo is a quick sample of how you can get started building apps using Nuxt 3 and Supabase. You can find a step by step guide of how to build out this app in the [Quickstart: Nuxt guide](https://supabase.io/docs/guides/with-nuxt-3).
|
||||
|
||||
This repo will demonstrate how to:
|
||||
|
||||
- sign users in with Supabase Auth using [magic link](https://supabase.io/docs/reference/dart/auth-signin#sign-in-with-magic-link)
|
||||
- store and retrieve data with [Supabase database](https://supabase.io/docs/guides/database)
|
||||
- store image files in [Supabase storage](https://supabase.io/docs/guides/storage)
|
||||
|
||||
## Getting Started
|
||||
|
||||
Before running this app, you need to create a Supabase project and copy [your credentials](https://supabase.io/docs/guides/with-nuxt-3#get-the-api-keys) to `.env`.
|
||||
Before running this app, you need to create a Supabase project and copy [your credentials](https://supabase.io/docs/guides/with-nuxt-3#get-the-api-keys) to `.env`.
|
||||
|
||||
Run the following command to launch it on `localhost:3000`
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
@@ -40,11 +42,11 @@ create policy "Public profiles are viewable by everyone."
|
||||
|
||||
create policy "Users can insert their own profile."
|
||||
on profiles for insert
|
||||
with check ( auth.uid() = id );
|
||||
with check ( (select auth.uid()) = id );
|
||||
|
||||
create policy "Users can update own profile."
|
||||
on profiles for update
|
||||
using ( auth.uid() = id );
|
||||
using ( (select auth.uid()) = id );
|
||||
|
||||
-- Set up Realtime!
|
||||
begin;
|
||||
@@ -64,4 +66,4 @@ create policy "Avatar images are publicly accessible."
|
||||
create policy "Anyone can upload an avatar."
|
||||
on storage.objects for insert
|
||||
with check ( bucket_id = 'avatars' );
|
||||
```
|
||||
```
|
||||
@@ -88,11 +88,11 @@ select
|
||||
|
||||
create policy "Users can insert their own profile." on profiles for insert
|
||||
with
|
||||
check (auth.uid () = id);
|
||||
check ((select auth.uid()) = id);
|
||||
|
||||
create policy "Users can update own profile." on profiles for
|
||||
update
|
||||
using (auth.uid () = id);
|
||||
using ((select auth.uid()) = id);
|
||||
|
||||
-- Set up Realtime!
|
||||
begin;
|
||||
|
||||
@@ -2,19 +2,17 @@
|
||||
|
||||
This repo is a quick sample of how you can get started building apps using [refine](https://github.com/refinedev/refine) and Supabase: users can sign up with a magic link and then update their account with public profile information, including a profile image.
|
||||
|
||||
|
||||
|
||||
## About refine
|
||||
|
||||
[refine](https://github.com/refinedev/refine) is a React-based framework for building data-intensive applications in no time ✨
|
||||
|
||||
refine offers lots of out-of-the box functionality for rapid development, without compromising extreme customizability. Use-cases include, but are not limited to admin panels, B2B applications and dashboards.
|
||||
|
||||
|
||||
- To learn more about **refine**, please check out the [Documentation](https://refine.dev/docs)
|
||||
- [Step up to refine tutorials.](https://refine.dev/docs/tutorial/introduction/index/)
|
||||
|
||||
## Available Scripts
|
||||
|
||||
### Running the development server.
|
||||
|
||||
```bash
|
||||
@@ -27,7 +25,6 @@ npm run dev
|
||||
npm run build
|
||||
```
|
||||
|
||||
|
||||
## Build from scratch
|
||||
|
||||
### 1. Create new project
|
||||
@@ -92,10 +89,10 @@ create policy "Public profiles are viewable by everyone."
|
||||
using ( true );
|
||||
create policy "Users can insert their own profile."
|
||||
on profiles for insert
|
||||
with check ( auth.uid() = id );
|
||||
with check ( (select auth.uid()) = id );
|
||||
create policy "Users can update own profile."
|
||||
on profiles for update
|
||||
using ( auth.uid() = id );
|
||||
using ( (select auth.uid()) = id );
|
||||
-- Set up Realtime!
|
||||
begin;
|
||||
drop publication if exists supabase_realtime;
|
||||
@@ -113,9 +110,6 @@ create policy "Anyone can upload an avatar."
|
||||
with check ( bucket_id = 'avatars' );
|
||||
```
|
||||
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
@@ -91,11 +91,11 @@ select
|
||||
|
||||
create policy "Users can insert their own profile." on profiles for insert
|
||||
with
|
||||
check (auth.uid () = id);
|
||||
check ((select auth.uid()) = id);
|
||||
|
||||
create policy "Users can update own profile." on profiles for
|
||||
update
|
||||
using (auth.uid () = id);
|
||||
using ((select auth.uid()) = id);
|
||||
|
||||
-- Set up Realtime!
|
||||
begin;
|
||||
|
||||
@@ -89,11 +89,11 @@ select
|
||||
|
||||
create policy "Users can insert their own profile." on profiles for insert
|
||||
with
|
||||
check (auth.uid () = id);
|
||||
check ((select auth.uid()) = id);
|
||||
|
||||
create policy "Users can update own profile." on profiles for
|
||||
update
|
||||
using (auth.uid () = id);
|
||||
using ((select auth.uid()) = id);
|
||||
|
||||
-- Set up Realtime!
|
||||
begin;
|
||||
|
||||
@@ -57,10 +57,10 @@ create policy "Public profiles are viewable by everyone."
|
||||
using ( true );
|
||||
create policy "Users can insert their own profile."
|
||||
on profiles for insert
|
||||
with check ( auth.uid() = id );
|
||||
with check ( (select auth.uid()) = id );
|
||||
create policy "Users can update own profile."
|
||||
on profiles for update
|
||||
using ( auth.uid() = id );
|
||||
using ( (select auth.uid()) = id );
|
||||
-- Set up Realtime!
|
||||
begin;
|
||||
drop publication if exists supabase_realtime;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
# Supabase Swift User Management
|
||||
|
||||
This repo is a quick sample of how you can get started building apps using Swift and Supabase. You can find a step by step guide of how to build out this app in the [Quickstart: Swift guide](https://supabase.io/docs/guides/with-swift).
|
||||
This repo is a quick sample of how you can get started building apps using Swift and Supabase. You can find a step by step guide of how to build out this app in the [Quickstart: Swift guide](https://supabase.io/docs/guides/with-swift).
|
||||
|
||||
This repo will demonstrate how to:
|
||||
|
||||
- Sign users in with Supabase Auth using [magic link](https://supabase.io/docs/reference/dart/auth-signin#sign-in-with-magic-link)
|
||||
- Store and retrieve data with [Supabase database](https://supabase.io/docs/guides/database)
|
||||
- Store image files in [Supabase storage](https://supabase.io/docs/guides/storage)
|
||||
@@ -39,11 +40,11 @@ create policy "Public profiles are viewable by everyone."
|
||||
|
||||
create policy "Users can insert their own profile."
|
||||
on profiles for insert
|
||||
with check ( auth.uid() = id );
|
||||
with check ( (select auth.uid()) = id );
|
||||
|
||||
create policy "Users can update own profile."
|
||||
on profiles for update
|
||||
using ( auth.uid() = id );
|
||||
using ( (select auth.uid()) = id );
|
||||
|
||||
-- Set up Realtime!
|
||||
begin;
|
||||
@@ -63,4 +64,4 @@ create policy "Avatar images are publicly accessible."
|
||||
create policy "Anyone can upload an avatar."
|
||||
on storage.objects for insert
|
||||
with check ( bucket_id = 'avatars' );
|
||||
```
|
||||
```
|
||||
@@ -1,17 +1,19 @@
|
||||
# Supabase Vue 3 User Management
|
||||
|
||||
This repo is a quick sample of how you can get started building apps using Vue 3 and Supabase. You can find a step by step guide of how to build out this app in the [Quickstart: Vue guide](https://supabase.io/docs/guides/with-vue-3).
|
||||
This repo is a quick sample of how you can get started building apps using Vue 3 and Supabase. You can find a step by step guide of how to build out this app in the [Quickstart: Vue guide](https://supabase.io/docs/guides/with-vue-3).
|
||||
|
||||
This repo will demonstrate how to:
|
||||
|
||||
- sign users in with Supabase Auth using [magic link](https://supabase.io/docs/reference/dart/auth-signin#sign-in-with-magic-link)
|
||||
- store and retrieve data with [Supabase database](https://supabase.io/docs/guides/database)
|
||||
- store image files in [Supabase storage](https://supabase.io/docs/guides/storage)
|
||||
|
||||
## Getting Started
|
||||
|
||||
Before running this app, you need to create a Supabase project and copy [your credentials](https://supabase.io/docs/guides/with-vue-3#get-the-api-keys) to `.env`.
|
||||
Before running this app, you need to create a Supabase project and copy [your credentials](https://supabase.io/docs/guides/with-vue-3#get-the-api-keys) to `.env`.
|
||||
|
||||
Run the following command to launch it on `localhost:5173`
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
@@ -40,11 +42,11 @@ create policy "Public profiles are viewable by everyone."
|
||||
|
||||
create policy "Users can insert their own profile."
|
||||
on profiles for insert
|
||||
with check ( auth.uid() = id );
|
||||
with check ( (select auth.uid()) = id );
|
||||
|
||||
create policy "Users can update own profile."
|
||||
on profiles for update
|
||||
using ( auth.uid() = id );
|
||||
using ( (select auth.uid()) = id );
|
||||
|
||||
-- Set up Realtime!
|
||||
begin;
|
||||
|
||||
Reference in new issue
Block a user