feat(synth): enable RLS support on views with security_invoker#30
Open
rlindgren wants to merge 1 commit into
Open
feat(synth): enable RLS support on views with security_invoker#30rlindgren wants to merge 1 commit into
rlindgren wants to merge 1 commit into
Conversation
Set security_invoker = true on generated views so that Row-Level Security policies on backing tables are evaluated as the querying user, not the view owner. Without this, RLS is silently bypassed when queries go through the view. This is safe for all deployments: when RLS is not enabled on the backing table, security_invoker has no effect. Backing tables are standard PostgreSQL tables (not hypertables), so RLS is fully supported on all data tables.
ce3431a to
5e82563
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR provides support for RLS for views with Postgres backing tables.
Set security_invoker = true on generated views so that Row-Level Security policies on backing tables are evaluated as the querying user, not the view owner. Without this, RLS is silently bypassed when queries go through the view.
This is safe for all deployments: when RLS is not enabled on the backing table, security_invoker has no effect. Backing tables are standard PostgreSQL tables (not hypertables), so RLS is fully supported on all data tables.
Although RLS is not strictly supported, this seemed like a freebie to maintain implicit support for it. I know that the spec says Postgres 12+ support, but I believe there is some code that already sets the floor at 15+ in practice, specifically:
NULLS NOT DISTINCT