Skip to content

[PM-34049] Fix PoliciesController authorize attribute#7303

Merged
eliykat merged 3 commits intomainfrom
ac/pm-34049/sso-jit-provisioning-does-not-prompt-for-master-password
Mar 25, 2026
Merged

[PM-34049] Fix PoliciesController authorize attribute#7303
eliykat merged 3 commits intomainfrom
ac/pm-34049/sso-jit-provisioning-does-not-prompt-for-master-password

Conversation

@eliykat
Copy link
Copy Markdown
Member

@eliykat eliykat commented Mar 25, 2026

🎟️ Tracking

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

📔 Objective

Fix for #7242, which added Authorize attributes to the PoliciesController.

GetMasterPasswordPolicy was updated to use the MemberRequirement, which assumes a confirmed member. This seemed appropriate because the member was being checked by UserId + OrgId, which matches a confirmed state. However, due to the invalid OrganizationUser provisioning bug, it actually matches invited users who need to set their password as well.

I have reverted the previous code, but moved it into an Authorize attribute in order to satisfy the tests (and more recent practices) of using attributes for authorization. This includes detailed xmldoc to explain this.

📸 Screenshots

@eliykat eliykat requested a review from a team as a code owner March 25, 2026 03:18
@eliykat eliykat requested a review from r-tome March 25, 2026 03:18
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 25, 2026

Logo
Checkmarx One – Scan Summary & Detailscc75e704-1c1c-4372-bde7-c323ba02f540

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

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 25, 2026

Codecov Report

❌ Patch coverage is 94.73684% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 57.89%. Comparing base (15e71aa) to head (987f9e5).
⚠️ Report is 131 commits behind head on main.

Files with missing lines Patch % Lines
...sole/Authorization/OrgUserLinkedToUserIdHandler.cs 94.44% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           main    #7303       +/-   ##
=========================================
+ Coverage      0   57.89%   +57.89%     
=========================================
  Files         0     2044     +2044     
  Lines         0    90068    +90068     
  Branches      0     8011     +8011     
=========================================
+ Hits          0    52148    +52148     
- Misses        0    36057    +36057     
- Partials      0     1863     +1863     

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

@eliykat eliykat added the ai-review-vnext Request a Claude code review using the vNext workflow label Mar 25, 2026
@eliykat eliykat closed this Mar 25, 2026
@eliykat eliykat reopened this Mar 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 25, 2026

Overall Assessment: APPROVE

This PR fixes a regression from PR 7242 where the MemberRequirement authorization attribute on GetMasterPasswordPolicy blocked invited users who have a linked UserId due to the SSO JIT provisioning bug (PM-34092). The fix introduces a new OrgUserLinkedToUserIdRequirement that performs a direct database lookup by UserId and OrganizationId, restoring the previous behavior while following the attribute-based authorization pattern. The new handler is well-documented with clear warnings against expanding its usage, and integration tests thoroughly cover unauthenticated, non-member, confirmed member, and invited-with-linked-UserId scenarios.

Code Review Details

No findings identified. The implementation is clean, follows established authorization handler patterns in this codebase, and includes appropriate documentation marking this as a temporary workaround to be removed when PM-34092 is resolved.

@sonarqubecloud
Copy link
Copy Markdown

@eliykat eliykat merged commit cafe4ff into main Mar 25, 2026
55 checks passed
@eliykat eliykat deleted the ac/pm-34049/sso-jit-provisioning-does-not-prompt-for-master-password branch March 25, 2026 09:27
@djsmith85 djsmith85 added the t:bugfix Change Type - Bugfix label Apr 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review-vnext Request a Claude code review using the vNext workflow t:bugfix Change Type - Bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants