Add Supabase hosting assets and database bootstrap - #4
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| -- Basic policies for Supabase row-level security (RLS) ---------------------- | ||
| ALTER TABLE platform.users ENABLE ROW LEVEL SECURITY; | ||
| ALTER TABLE platform.projects ENABLE ROW LEVEL SECURITY; | ||
| ALTER TABLE platform.sessions ENABLE ROW LEVEL SECURITY; | ||
| ALTER TABLE platform.token_usage ENABLE ROW LEVEL SECURITY; | ||
| ALTER TABLE platform.api_keys ENABLE ROW LEVEL SECURITY; | ||
|
|
||
| CREATE POLICY users_self_access ON platform.users | ||
| USING (auth.uid() = id) | ||
| WITH CHECK (auth.uid() = id); | ||
|
|
||
| CREATE POLICY projects_owner_access ON platform.projects | ||
| USING (auth.uid() = owner_id) | ||
| WITH CHECK (auth.uid() = owner_id); | ||
|
|
||
| CREATE POLICY sessions_owner_access ON platform.sessions | ||
| USING (auth.uid() = user_id) | ||
| WITH CHECK (auth.uid() = user_id); | ||
|
|
||
| CREATE POLICY token_usage_owner_access ON platform.token_usage | ||
| USING (auth.uid() = user_id); | ||
|
|
||
| CREATE POLICY api_keys_owner_access ON platform.api_keys | ||
| USING (auth.uid() = user_id) | ||
| WITH CHECK (auth.uid() = user_id); | ||
|
|
||
| -- Privileges for service role ------------------------------------------------ | ||
| GRANT USAGE ON SCHEMA platform, telemetry, analytics TO postgres; | ||
| GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA platform TO postgres; | ||
| GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA telemetry TO postgres; | ||
| GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA analytics TO postgres; | ||
| GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA platform TO postgres; |
There was a problem hiding this comment.
Grant platform privileges to Supabase client roles
The bootstrap script enables RLS and defines policies but only grants schema/table privileges to the postgres service role. Supabase clients use the anon/authenticated roles when calling the new supabaseClient helpers; without explicit GRANT USAGE/SELECT/INSERT/UPDATE on the platform, telemetry, and analytics schemas and tables, every call such as listProjects or upsertProfile will fail with permission denied even if the RLS policy would allow it. You need to grant the necessary privileges to the client roles (and restrict sensitive functions) so the app can actually read/write data.
Useful? React with 👍 / 👎.
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_68f56c8caedc8329acbc2d5de9e0a053