-
Notifications
You must be signed in to change notification settings - Fork 0
Add skip_permissions_check option to Psycopack
#45
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
Conversation
Previously, the permissions check was done each time a Psycopack object was instantiated. The check looks for the permissions needed for the complete operation, including all the individual steps. However, one step, backfill(), doesn't require the much higher elevated permissions that the other steps require. Following the principle of least privilege, it might be desirable to run the backfill() step using a Postgres user with lower privileges than the user used for the other steps. This change adds a skip_permissions_check option to Psycopack which enables its use with a less-privileged Postgres user.
Coverage Report Results
1 empty file skipped. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a new option, skip_permissions_check, to the Psycopack class to allow bypassing permission checks when a less-privileged PostgreSQL user is used for the backfill step. Key changes include:
- Modification of the Psycopack constructor in src/psycopack/_repack.py to accept and conditionally bypass permission checks.
- Addition of a new test case in tests/test_repack.py to verify that when skip_permissions_check is set to True, the permissions check is not executed.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/test_repack.py | New test ensuring _check_user_permissions is not called when skip_permissions_check is enabled |
| src/psycopack/_repack.py | Added skip_permissions_check parameter and conditional check to bypass permission validation |
Comments suppressed due to low confidence (1)
src/psycopack/_repack.py:137
- [nitpick] Consider adding documentation for the new 'skip_permissions_check' parameter in the class docstring and init method to clarify its intended usage.
skip_permissions_check: bool = False,
s-cooper18
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense
flpcury
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me as a workaround.
On the long-term it would be better to have more granular permission checking (permission to instantiate Psycopack != permission to backfill != permission to sync schemas, etc). That way, there should never be a use case for skipping permission checking
Previously, the permissions check was done each time a Psycopack object was instantiated. The check looks for the permissions needed for the complete operation, including all the individual steps. However, one step,
backfill(), doesn't require the much higher elevated permissions that the other steps require. Following the principle of least privilege, it might be desirable to run thebackfill()step using a Postgres user with lower privileges than the user used for the other steps. (Backfilling only does DML operations, whereas most of the other steps do DDL operations that require higher privileges.)This change adds a skip_permissions_check option to Psycopack which enables its use with a less-privileged Postgres user.