개발

[supabase] Supabase Publishable Key vs Secret Key 정리

ttoance 2025. 8. 29. 17:21
반응형

 

1. project settings 클릭

 

2. api keys 탭 > create new key 클릭 

 

3. add new secret key 로 등록 

 

 

4. name, description 입력 후 등록하면 된다. 

 

 

참고로, publishable key와 secret key가 있는데 

https://supabase.com/docs/guides/api/api-keys 여기 문서를 보면 

Type Format Privileges Availability Use
Publishable key sb_publishable_... Low Platform Safe to expose online: web page, mobile or desktop app, GitHub actions, CLIs, source code.
Secret keys sb_secret_... Elevated Platform Only use in backend components of your app: servers, already secured APIs (admin panels), Edge Functions, microservices, etc. They provide full access to your project's data, bypassing Row Level Security.
anon JWT (long lived) Low Platform, CLI Exactly like the publishable key.
service_role JWT (long lived) Elevated Platform, CLI Exactly like secret keys.

 

Publishable key와 anon 키는 권한 수준이 낮아 클라이언트 환경에서 사용하기에 안전하다. 웹, 모바일, 데스크톱 앱뿐 아니라 GitHub Actions, CLI, 소스 코드에도 노출될 수 있다.

 

반면 Secret key와 service_role 키는 권한이 높아 프로젝트 데이터 전체에 접근할 수 있으며, Row Level Security를 무시한다. 따라서 반드시 서버, 보안된 API, Edge Functions, 마이크로서비스 같은 백엔드 환경에서만 사용해야 한다.

 

정리하면, 클라이언트에서는 Publishable key / anon을, 백엔드에서는 Secret key / service_role을 사용하는 것이 안전한 방식이다.

 

 

 

반응형