-
Notifications
You must be signed in to change notification settings - Fork 2
Permissions Module Refactor and Direct Testing #607
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
Permissions Module Refactor and Direct Testing #607
Conversation
…g in calibration publishing permissions
…ions and 401 for missing user data
…ufficient permissions when user data is missing
…nd testability - Refactored the `permissions.py` file into a permissions module - Entities now have their own has_permission function, and the core `has_permission` function acts as a dispatcher. This structure significantly improves readability and testability of the permissions boundary. It also greatly improves its extensibility for future permissions updates. - Added comprehensive tests for all implemented permissions. Tests are modular and can be easily added to and changed.
…ation permissions When fetching score sets via this method, score calibration relationships were being unset in an unsafe manner. Because of this, functions in this router were refactored to access score sets directly and load the score set contributors directly when loading calibrations.
…stency and duplication - Added unified deny action handler for reduced duplication - Removed now unused deny action tests from score calibration, score set, and user permission tests. - Updated error messages in various tests to consistently reference the entity type (e.g., "ScoreCalibration", "ScoreSet", "User") in the detail messages. - Adjusted test assertions to ensure they check for the correct error messages when permissions are insufficient or entities are not found. - Renamed tests to clarify expected outcomes, particularly for contributor permissions.
52d18b5 to
3359a1d
Compare
3359a1d to
d4c685c
Compare
jstone-dev
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.
These changes look great to me.
One small comment: In exception messages that may be user-facing, I'm not sure I would use model class names like ScoreSet and Experiment.
jstone-dev
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.
These changes look great to me.
One small comment: In exception messages that may be user-facing, I'm not sure I would use model class names like ScoreSet and Experiment.
…n manipulating domain list
See #613 for a possible solution to the pain renaming many distributed user facing model names.
This pull request introduces a new, modular permission system for MaveDB entities. The new system centralizes permission checks, provides clear separation by entity type, and offers a unified API for permission evaluation and enforcement. It adds comprehensive documentation, consistent logging, and improved error handling for permission-related operations.
Key changes include:
Core Permission Framework:
has_permissionandassert_permissionfunctions insrc/mavedb/lib/permissions/core.py, which dispatch requests to entity-specific permission handlers and raise exceptions on denial.Actionenum insrc/mavedb/lib/permissions/actions.pyto standardize supported permission actions across all entity types.PermissionResponsemodel insrc/mavedb/lib/permissions/models.pyto encapsulate permission results, HTTP status codes, and messages, with integrated logging.PermissionExceptionfor consistent exception handling when permission is denied.__init__.py) to expose the main permission API and provide usage examples.Entity-Specific Permission Handlers:
Test Updates
These changes lay the foundation for a robust and extensible permission system, making permission checks more maintainable and consistent across the codebase.