[PM-34595] Add provider authorization attributes#7389
Conversation
Introduces declarative authorization pattern for Provider-based endpoints following the same approach as the existing Organization authorization infrastructure. No production code behavior changes — handler and requirements are registered but not yet wired to any controllers. New: - IProviderRequirement: base interface for provider authorization requirements - ProviderRequirementHandler: central handler that resolves provider claims from route/context and delegates to requirement implementations - ProviderClaimsExtensions: helpers to parse provider membership from claims - ProviderAdminRequirement, ProviderUserRequirement, ManageProviderUsersRequirement - HttpContextExtensions.GetProviderId(): route param helper (mirrors GetOrganizationId) - DI registration for ProviderRequirementHandler - Unit tests for all new types
|
New Issues (121)Checkmarx found the following issues in this Pull Request
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7389 +/- ##
==========================================
+ Coverage 58.44% 58.46% +0.02%
==========================================
Files 2060 2064 +4
Lines 91178 91226 +48
Branches 8114 8122 +8
==========================================
+ Hits 53287 53335 +48
Misses 36002 36002
Partials 1889 1889 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Bitwarden Claude Code ReviewOverall Assessment: APPROVE This PR introduces declarative authorization infrastructure for Provider endpoints, mirroring the existing Organization authorization pattern. The changes include a new No issues found. The implementation is consistent with established patterns, fails closed on missing authentication, and has thorough test coverage for all new types. |
|






Tracking
https://bitwarden.atlassian.net/browse/PM-34595
Objective
Introduces the declarative authorization pattern for Provider endpoints, following the same approach as the existing Organization authorization infrastructure (see
OrganizationRequirementHandler).This will let us change from the current imperative pattern, which relies on the
CurrentContextgod class:To a declarative pattern:
This PR is plumbing only — no controller behavior changes. The handler and requirements are registered but not yet wired to any endpoints. A follow-up PR will update the controllers to use these requirements.
There is also some reorganization of the file structure to better accommodate these new files.
Code changes
New types:
IProviderRequirement— base interface for provider authorization requirementsProviderRequirementHandler— central handler that extracts the provider from route/claims and delegates to requirement implementationsProviderClaimsExtensions— helpers to parseCurrentContextProviderfrom aClaimsPrincipalHttpContextExtensions.GetProviderId()— route param helper mirroring existingGetOrganizationId()ManageProviderUsersrequirement.