-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[PM-18087] Add cipher permissions to response models #5418
base: main
Are you sure you want to change the base?
[PM-18087] Add cipher permissions to response models #5418
Conversation
…ganization properties
…bility - Split large test method into smaller, focused methods - Added helper methods for creating test data and performing assertions - Improved test coverage for cipher permissions in different scenarios - Maintained existing test logic while enhancing code structure
- Removed redundant helper methods for permission assertions - Simplified test methods for GetCipherPermissionsForOrganizationAsync, GetManyByUserIdAsync, and GetByIdAsync - Maintained existing test coverage for cipher manage permissions - Improved code readability and reduced code duplication
…missions - Added new test method GetCipherPermissionsForOrganizationAsync_ManageProperty_RespectsCollectionGroupRules - Implemented helper method CreateCipherInOrganizationCollectionWithGroup to support group-based collection permission testing - Verified manage permissions are correctly applied based on group collection access settings
- Updated CipherDetails_Create, CipherDetails_CreateWithCollections, and CipherDetails_Update stored procedures - Added @manage parameter with comment "-- not used" - Included new stored procedure implementations in migration script - Consistent with previous work on adding Manage property to cipher details
This change introduces organization ability context to various cipher response models across multiple controllers. The modifications include: - Updating CipherResponseModel to include permissions based on user and organization ability - Modifying CiphersController methods to fetch and pass organization abilities - Updating SyncController to include organization abilities in sync response - Adding organization ability context to EmergencyAccessController response generation
This change simplifies the EmergencyAccessController by removing unnecessary organization ability fetching and passing. Since emergency access only retrieves personal ciphers, the organization ability context is no longer needed in the response generation.
Remove unnecessary JsonConstructor attribute and simplify constructor initialization for EmergencyAccessViewResponseModel
New Issues (7)Checkmarx found the following issues in this Pull Request
Fixed Issues (29)Great job! The following issues were fixed in this Pull Request
|
Extract methods to simplify organization ability fetching for ciphers, reducing code duplication and improving readability. Added two private helper methods: - GetOrganizationAbilityAsync: Retrieves organization ability for a single cipher - GetManyOrganizationAbilitiesAsync: Retrieves organization abilities for multiple ciphers
Modify test methods to: - Replace GetProperUserId with GetUserByPrincipalAsync - Use User object instead of separate userId - Update mocking to return User object - Ensure user ID is correctly set in test scenarios
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5418 +/- ##
==========================================
- Coverage 44.48% 44.37% -0.12%
==========================================
Files 1533 1535 +2
Lines 71075 70596 -479
Branches 6377 6319 -58
==========================================
- Hits 31618 31324 -294
+ Misses 38090 37927 -163
+ Partials 1367 1345 -22 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…/add-cipher-permissions-to-response-models
…rs and models - Update CiphersController to use GetOrganizationAbilitiesAsync instead of individual methods - Modify CipherResponseModel and CipherDetailsResponseModel to accept organization abilities dictionary - Update CipherPermissionsResponseModel to handle organization abilities lookup - Remove deprecated organization ability retrieval methods - Simplify sync and emergency access response model handling of organization abilities
- Delete unused method from IApplicationCacheService interface - Remove corresponding implementation in InMemoryApplicationCacheService - Continues cleanup of organization ability retrieval methods
…eval - Add organization abilities retrieval in test setup for PutCollections_vNext method - Ensure consistent mocking of IApplicationCacheService in test scenarios
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.
Looking good, moving the dict down into the response model addressed my previous concerns.
src/Api/Vault/Models/Response/CipherPermissionsResponseModel.cs
Outdated
Show resolved
Hide resolved
src/Core/Vault/Authorization/Permissions/NormalCipherPermissions.cs
Outdated
Show resolved
Hide resolved
test/Core.Test/Vault/Authorization/Permissions/NormalCipherPermissionTests.cs
Outdated
Show resolved
Hide resolved
…se-models # Conflicts: # src/Core/Vault/Authorization/Permissions/NormalCipherPermissions.cs # test/Core.Test/Vault/Authorization/Permissions/NormalCipherPermissionTests.cs
2c03a19
to
5e2d973
Compare
|
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-18087
📔 Objective
CipherPermissionsResponseModel
to explicitly communicate cipher permissionsDelete
andRestore
boolean propertiesNormalCipherPermissions
to calculate these valuesCipherResponseModel
to include the new permissions propertyOrganizationAbility
parameter to relevant response model constructors to support permission calculationsImplementation Details
OrganizationAbility
for organizational ciphers📸 Screenshots
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:
) or similar for great changes:memo:
) or ℹ️ (:information_source:
) for notes or general info:question:
) for questions:thinking:
) or 💭 (:thought_balloon:
) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:
) for suggestions / improvements:x:
) or:warning:
) for more significant problems or concerns needing attention:seedling:
) or ♻️ (:recycle:
) for future improvements or indications of technical debt:pick:
) for minor or nitpick changes