Skip to content

[PM-34595] Update provider controllers to use authz attribute#7450

Open
eliykat wants to merge 11 commits intomainfrom
ac/pm-34595/provider-authorization-wiring-2
Open

[PM-34595] Update provider controllers to use authz attribute#7450
eliykat wants to merge 11 commits intomainfrom
ac/pm-34595/provider-authorization-wiring-2

Conversation

@eliykat
Copy link
Copy Markdown
Member

@eliykat eliykat commented Apr 11, 2026

🎟️ Tracking

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

📔 Objective

Primary objective: update provider controllers to use the Authorize attribute and the requirements added in #7389 . Add some basic tests for each controller - each endpoint is not tested comprehensively, but there are 'sentinel' tests to assure us that the attributes are working as intended end-to-end.

Secondary objective: break inheritance relationship between ProviderClientsController and the base controller classes still owned and used by Billing. This should be done to clarify our cross-team interfaces, and because the base controller implements its own authorization checks which are now duplicative. Changes:

  • bring the TryGetBillableProvider logic into our controller as a private method - remove the role check which is handled by the attribute
  • update our base controller class to expose response types directly, so that we can use these instead of the equivalent methods on the base billing controller

📸 Screenshots

@eliykat eliykat changed the title Ac/pm 34595/provider authorization wiring 2 [PM-34595] Update provider controllers to use authz attributes Apr 11, 2026
@eliykat eliykat changed the title [PM-34595] Update provider controllers to use authz attributes [PM-34595] Update provider controllers to use authz attribute Apr 11, 2026
Comment on lines 131 to 139
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not used the base class helper here because I'm not sure this should be a 401 (more likely a 403) and I don't want to encourage other consumers to include error messages in their 401 responses. However, it was out of scope to address further here.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 11, 2026

Logo
Checkmarx One – Scan Summary & Detailsbc40ca89-d5b4-4cc5-bde1-d7bf4865c054

Great job! No new security vulnerabilities introduced in this pull request

@eliykat eliykat added the ai-review Request a Claude code review label Apr 11, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 11, 2026

Bitwarden Claude Code Review

Overall Assessment: APPROVE

This PR migrates four provider controllers (ProvidersController, ProviderUsersController, ProviderOrganizationsController, ProviderClientsController) from imperative ICurrentContext authorization checks to declarative [Authorize<T>] attributes. The authorization mapping was verified correct: ProviderUser maps to ProviderUserRequirement, ProviderProviderAdmin/ManageProviderOrganizations map to ProviderAdminRequirement, and ProviderManageUsers maps to ManageProviderUsersRequirement. The ProviderClientsController cleanly breaks its inheritance from BaseProviderController, inlining TryGetBillableProviderAsync as a private method with the role check correctly removed since it is now handled by the attribute. The new NoopAuthorizeAttribute preserves class-level authentication while signaling intentional absence of additional authorization, and integration tests comprehensively verify the expected HTTP status codes for each role.

Code Review Details

No findings.

@eliykat eliykat marked this pull request as ready for review April 11, 2026 01:14
@eliykat eliykat requested a review from a team as a code owner April 11, 2026 01:14
@eliykat eliykat requested a review from JimmyVo16 April 11, 2026 01:14
@eliykat eliykat requested a review from sven-bitwarden April 11, 2026 01:15
@eliykat
Copy link
Copy Markdown
Member Author

eliykat commented Apr 11, 2026

@JimmyVo16 and @sven-bitwarden this will be of interest to you given our tech debt priorities - this is just some work that I already had stashed, and I expect the other controllers will follow this pattern.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 11, 2026

Codecov Report

❌ Patch coverage is 86.20690% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.87%. Comparing base (f2141b9) to head (65ffd54).

Files with missing lines Patch % Lines
...pi/AdminConsole/Controllers/ProvidersController.cs 25.00% 6 Missing ⚠️
...nConsole/Controllers/BaseAdminConsoleController.cs 90.00% 1 Missing ⚠️
...inConsole/Controllers/ProviderClientsController.cs 97.29% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7450      +/-   ##
==========================================
+ Coverage   58.66%   58.87%   +0.20%     
==========================================
  Files        2066     2066              
  Lines       91089    91059      -30     
  Branches     8106     8092      -14     
==========================================
+ Hits        53440    53610     +170     
+ Misses      35740    35534     -206     
- Partials     1909     1915       +6     

☔ 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.

Copy link
Copy Markdown
Contributor

@JimmyVo16 JimmyVo16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good and approved. Just one question about the [AllowAnonymous].

@eliykat eliykat requested a review from JimmyVo16 April 14, 2026 03:19
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request a Claude code review needs-qa

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants