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

Merged
merged 2 commits into from
Aug 15, 2025

Conversation

ebg1223
Copy link
Contributor

@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!

Fixes #42
Fixes #722


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

Copy link

pkg-pr-new bot commented Aug 15, 2025

Open in StackBlitz

npm i https://pkg.pr.new/get-convex/convex-helpers@720

commit: b98573f

Copy link
Collaborator

@ianmacartney ianmacartney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you! long requested, and nicely implemented

@ianmacartney ianmacartney merged commit 4394a55 into get-convex:main Aug 15, 2025
3 checks passed
@ianmacartney
Copy link
Collaborator

out in [email protected]

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.

Request: Row Level Security default deny RLS: Option to give no access by default
2 participants