-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[PM-29186] Remove 2FA user interface from premium method signatures #6684
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6684 +/- ##
==========================================
+ Coverage 53.33% 57.46% +4.13%
==========================================
Files 1909 1926 +17
Lines 85118 85711 +593
Branches 7648 7686 +38
==========================================
+ Hits 45398 49258 +3860
+ Misses 37965 34606 -3359
- Partials 1755 1847 +92 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
New Issues (1)Checkmarx found the following issues in this Pull Request
|
|
Claude finished @trmartin4's task —— View job Code Review CompleteTasks
Overall AssessmentThis is an architecturally sound refactoring that removes a misleading interface abstraction. The premium checking logic has evolved beyond its original 2FA context, and this PR correctly narrows the method signatures to reflect their actual usage. Finding Summary:
Critical IssuesFinding 1: Test Compilation Failure ❌The test file private class TestTwoFactorProviderUser : ITwoFactorProvidersUser
{
// ... other members ...
public bool GetPremium() // ← This method no longer exists in the interface
{
return Premium;
}
}Impact: The build will fail with a compilation error stating that Fix: Remove the Why this was missed: The test class is private and only used within that test file, so it's easy to overlook during interface refactoring. Suggested ImprovementsFinding 2: Incomplete Null-Safety Migration ⛏️The
Suggestion: While not strictly required for this PR, consider filing a follow-up issue to complete the null-safety migration for Finding 3: Documentation Could Be More Prescriptive 🎨The added XML documentation for Current documentation (lines 68-76 of /// <summary>
/// Checks if the user has inherited access to premium features through an organization.
///
/// This primarily serves as a means to communicate to the client when a user has inherited their premium status
/// through an organization. Feature gating logic probably should not be behind this check.
/// </summary>
Task<bool> HasPremiumFromOrganization(User user);Suggestion: The documentation could be more explicit about when NOT to use /// <summary>
/// Checks if the user has inherited access to premium features through an organization.
///
/// This method is intended ONLY for UI/client communication purposes to display the source of premium access.
/// DO NOT use this method for feature gating - use <see cref="CanAccessPremium"/> instead.
/// </summary>Why: The current wording "probably should not" is somewhat ambiguous. Making it more prescriptive ("DO NOT use") helps prevent future misuse. Architecture & Security AssessmentPositive Findings:
Code Quality:
Test Coverage:
Verification Steps Performed
Action Items for Author
SummaryThis PR successfully removes a misleading abstraction and clarifies the purpose of premium checking methods. The refactoring is well-justified and architecturally sound. One critical test compilation issue must be fixed before merge. The changes align with Bitwarden's code quality standards and security requirements. Recommendation: Request changes (due to test compilation failure) |
enmande
left a comment
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.
Thank you; this adds a ton of clarity, and the comments are fantastic.
Just proposing a couple of ⛏️ -level suggestions to make the XML comments between the two IUserService methods more similar, but totally not necessary.


🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-29186
📔 Objective
During the refinement for upcoming changes to some of our 2FA setup logic, the Auth team discovered that there is a misleading signature on the
CanAccessPremium()andHasPremiumFromOrganization()methods onUserService. These methods as written accepted anITwoFactorProvidersUser, but the premium checks have evolved over time to be consumed at various other points in the code that have nothing to do with 2FA.This PR proposes to change those signatures to accept a
Userinstead. This does not break any existing behavior, becauseUserimplementsITwoFactorProvidersUser. The only thing that would break would be if other implementors ofITwoFactorProvidersUser- namelyOrganizationUserUserDetails- needed to be used as input toCanAccessPremium()orHasPremiumFromOrganization(). However, a check of the code shows that this user representation does not consume those methods.If we were to need to have an abstraction for an entity that has premium, we should create an
IPremiumUserinterface at that point to maintain the proper abstraction.⏰ 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