Repository navigation
fix: restrict the realtime schema - #1993
Conversation
Apply schema restrictions when supautils grants are available to avoid unintentional and unexpected changes to realtime schema that's supposed to be protected. Closes REAL-778 Closes REAL-773
This comment has been minimized.
This comment has been minimized.
| begin | ||
| if not exists (select from pg_roles where rolname = 'supabase_realtime_admin') then | ||
| create user supabase_realtime_admin noinherit createrole login replication password 'postgres'; | ||
| create role supabase_realtime_admin with noinherit nologin noreplication; |
| else: (_ -> {:ignore, nil}) | ||
| end) do | ||
| value | ||
| case Cachex.fetch(__MODULE__, cache_key(name), fn _key -> |
There was a problem hiding this comment.
This change is unrelated but I found it while testing and it was small enough to include in this PR. See the tests.
| execute("REVOKE ALL ON realtime.schema_migrations FROM postgres, dashboard_user, anon, authenticated, service_role") | ||
|
|
||
| execute( | ||
| "REVOKE INSERT, UPDATE, DELETE, TRUNCATE, REFERENCES, TRIGGER ON realtime.schema_migrations FROM supabase_realtime_admin" |
There was a problem hiding this comment.
SELECT is still required but it's safe.
There was a problem hiding this comment.
why supabase_realtime_admin here matters?
There was a problem hiding this comment.
Checked again and it doesn't. I thought it was impacting tests but nope so I added supabase_realtime_adminto the REVOKE ALL ON realtime.schema_migrations because only supabase_admin is supposed to use that table.
There was a problem hiding this comment.
These are the most important assertions. Need to double check if those changes are not too restrictive.
# Conflicts: # .github/workflows/integration_tests.yml # .github/workflows/tests.yml # test/test_helper.exs
CRAP Score Report |
|
🎉 This PR is included in version 2.112.7 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## What kind of change does this PR introduce? Make it clear what users can and can't do on `realtime` schema. ## What is the current behavior? After supabase/realtime#1993 creating or altering the realtime schema is no longer allowed, but some users are still trying to execute `ALTER TABLE realtime.messages ENABLE ROW LEVEL SECURITY` or trying to create objects on that schema. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Clarified Realtime schema protections, including a caution about how the `realtime` schema is restricted and what permission errors to expect when creating objects there. * Confirmed that row level security is enabled by default on `realtime.messages`, and that managing its RLS policies is supported. * Documented the additional binary-capable function, `realtime.send_binary`, alongside the existing `realtime.send` behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
db_userand removesdb_user_realtime. The restriction is controlled by migrations only.use_supabase_realtime_adminRef REAL-25, REAL-527, REAL-630, REAL-631, REAL-773, REAL-778
Task SEC-562 is still open.