Add option for default deny behavior to RLS Helpers #720
+186
−7
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.
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