Skip to content

[PM-12473] Add dedicated CollectionUser and CollectionGroup authorization handlers#7442

Open
r-tome wants to merge 26 commits intomainfrom
ac/pm-12473/move-collectionuser-and-collectiongroup-logic-to-dedicated-handlers
Open

[PM-12473] Add dedicated CollectionUser and CollectionGroup authorization handlers#7442
r-tome wants to merge 26 commits intomainfrom
ac/pm-12473/move-collectionuser-and-collectiongroup-logic-to-dedicated-handlers

Conversation

@r-tome
Copy link
Copy Markdown
Contributor

@r-tome r-tome commented Apr 10, 2026

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-12473

📔 Objective

Extracts user-access and group-access authorization from BulkCollectionAuthorizationHandler into dedicated CollectionUserAuthorizationHandler and CollectionGroupAuthorizationHandler, gated behind a feature flag.

r-tome added 20 commits April 8, 2026 15:31
…or user and group access modifications, and add corresponding unit tests to ensure correct behavior when the feature flag is enabled.
…for authorization logic based on user roles and feature flags.
… authorization based on roles and feature flags
…s and CollectionUserAuthorizationHandlerTests for clarity and consistency, enhancing readability and understanding of test purposes.
…onHandler to the authorization handler registration
…ss authorization, refactoring authorization logic to support new operations and enhancing unit tests for various scenarios.
…roup access authorization, refactoring authorization logic and adding new methods for improved access management. Update unit tests to cover new scenarios and ensure correct behavior with feature flag enabled.
…ks for collection access authorization, enhancing the authorization logic for user and group operations. Introduce new methods for improved access management and update unit tests to validate behavior with the feature flag enabled.
…a user attempts to add themselves to a collection
…thorization methods. Introduce separate methods for user and group access changes, enhancing clarity and maintainability of the authorization logic. Update authorization checks to align with new method structure.
…tionHandlerTests to throw BadRequestException for self-assignment attempts. Enhance unit tests to validate new exception handling and authorization logic for user and group operations.
…ccess checks. Update methods to use ICollection for collections and ensure early return for empty collections, enhancing clarity and efficiency in authorization handling.
…ctions in authorization checks. Update CanManageCollectionsAsync method to include organization role and permissions, allowing Admin and Owner roles to manage orphaned collections. Add unit tests to validate authorization logic for various user roles and permissions regarding orphaned collections.
…tions in authorization checks. Update CanManageCollectionsAsync method to include organization context, allowing Admin and Owner roles to manage orphaned collections. Add unit tests to validate authorization logic for various user roles and permissions regarding orphaned collections.
@r-tome r-tome added ai-review-vnext Request a Claude code review using the vNext workflow ai-review Request a Claude code review and removed ai-review Request a Claude code review labels Apr 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 10, 2026

Logo
Checkmarx One – Scan Summary & Details85498e8a-dbf1-4766-abe7-448325741e39


New Issues (2) Checkmarx found the following issues in this Pull Request
# Severity Issue Source File / Package Checkmarx Insight
1 HIGH Path_Traversal /src/Api/Controllers/SelfHosted/SelfHostedOrganizationLicensesController.cs: 56
detailsMethod at line 56 of /src/Api/Controllers/SelfHosted/SelfHostedOrganizationLicensesController.cs gets dynamic data from the model element. This ...
Attack Vector
2 MEDIUM CSRF /src/Api/Auth/Controllers/AccountsController.cs: 452
detailsMethod at line 452 of /src/Api/Auth/Controllers/AccountsController.cs gets a parameter from a user request from model. This parameter value flow...
Attack Vector

…ongroup-logic-to-dedicated-handlers

# Conflicts:
#	src/Core/Constants.cs
@r-tome r-tome requested a review from eliykat April 13, 2026 12:05
@r-tome r-tome changed the title Ac/pm 12473/move collectionuser and collectiongroup logic to dedicated handlers [PM-12473] Add dedicated CollectionUser and CollectionGroup authorization handlers Apr 13, 2026
…GroupAccess as obsolete, replacing them with CollectionUserOperations and CollectionGroupOperations respectively. Update documentation to reflect changes.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 13, 2026

Bitwarden Claude Code Review

Overall Assessment: APPROVE

This PR introduces dedicated CollectionUserAuthorizationHandler and CollectionGroupAuthorizationHandler classes behind the pm-12473-collection-user-collection-group-authorization-handlers feature flag. The new handlers replace the combined ModifyUserAccess/ModifyGroupAccess operations in BulkCollectionAuthorizationHandler with granular Create/Update/Delete operations, enabling more precise authorization for collection access changes. The authorization logic in the new handlers correctly mirrors the existing behavior, the feature flag dual-gating (old handler returns without succeeding, new handlers return without handling) is consistent, and the self-assignment protection has been properly migrated into the CollectionUserAuthorizationHandler.CanCreateUserAccessAsync method.

Code Review Details

No actionable findings identified. The authorization logic, feature flag gating, and test coverage are all sound.

@r-tome r-tome removed the ai-review-vnext Request a Claude code review using the vNext workflow label Apr 13, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 13, 2026

Codecov Report

❌ Patch coverage is 91.51376% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.80%. Comparing base (f2141b9) to head (4f2d64d).

Files with missing lines Patch % Lines
...Collections/CollectionGroupAuthorizationHandler.cs 87.25% 7 Missing and 6 partials ⚠️
src/Api/Controllers/CollectionsController.cs 86.74% 6 Missing and 5 partials ⚠️
.../Collections/CollectionUserAuthorizationHandler.cs 91.89% 4 Missing and 5 partials ⚠️
...Console/Controllers/OrganizationUsersController.cs 94.20% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7442      +/-   ##
==========================================
+ Coverage   58.66%   58.80%   +0.14%     
==========================================
  Files        2066     2072       +6     
  Lines       91089    91489     +400     
  Branches     8106     8179      +73     
==========================================
+ Hits        53440    53804     +364     
- Misses      35740    35759      +19     
- Partials     1909     1926      +17     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…ongroup-logic-to-dedicated-handlers

# Conflicts:
#	src/Core/Constants.cs
@r-tome r-tome marked this pull request as ready for review April 13, 2026 15:51
@r-tome r-tome requested review from a team as code owners April 13, 2026 15:51
@r-tome r-tome requested a review from jaasen-livefront April 13, 2026 15:51
r-tome added 2 commits April 14, 2026 11:59
…ongroup-logic-to-dedicated-handlers

# Conflicts:
#	src/Api/AdminConsole/Controllers/GroupsController.cs
@sonarqubecloud
Copy link
Copy Markdown

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.

1 participant