DEV Community

Beaver Bridge
Beaver Bridge

Posted on

supabase에 새 role 추가하기

새 사용자가 raw_user_password에 insert를 하면, 트리거가 돌면서 public.users, auth.users에 무언가 작업을 한다.

-- 최초 한 번만 실행하면 됨
grant usage on schema extensions to public;
Enter fullscreen mode Exit fullscreen mode

사용자 생성

CREATE ROLE test_user INHERIT LOGIN  PASSWORD 'test_user_password'; -- 사용자 생성
GRANT USAGE ON SCHEMA public TO test_user; -- public 스키마 접근 허용
GRANT USAGE ON SCHEMA auth TO test_user; -- auth 스키마 접근 허용
GRANT insert, TRIGGER ON TABLE public.raw_user_password TO test_user; -- 사용할 테이블들 권한 허용
GRANT select, update ON TABLE public.users TO test_user;
GRANT select, update ON TABLE auth.users TO test_user;
Enter fullscreen mode Exit fullscreen mode

사용자 삭제

접근 허용한 권한들을 모두 회수해야 삭제가 가능하다.

revoke USAGE ON SCHEMA public from test_user;
revoke USAGE ON SCHEMA auth from test_user;
revoke all ON TABLE public.raw_user_password from test_user;
revoke all ON TABLE public.users from test_user;
revoke all ON TABLE auth.users from test_user;
drop role test_user;
Enter fullscreen mode Exit fullscreen mode

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay