Skip to content

Add option for default deny behavior to RLS Helpers #720

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ebg1223
Copy link

@ebg1223 ebg1223 commented Aug 5, 2025

Tl;dr- adds a config option to RLS helpers to specify default deny behavior, instead of current default allow behavior.

Prior to this PR, using row level security helpers would always allow a request if a function was not explicitly provided for a method on a table.

This PR adds a config type RLSConfig, with a single option, defaultPolicy, which accepts either "allow" or "deny".
The wrapDatabaseReader and wrapDatabaseWriter optionally accept an object of this type.

If no config object is provided, the default behavior remains the same, and the request will be allowed if no method handler for the table is provided.
If {defaultPolicy: "deny"} is provided, access will be denied, unless a method handler for the table is provided, and returns true.

Tests also added to validate behavior.

Thank you for reading!


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. - I Agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant