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

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more