Skip to content

Conversation

@cyprain-okeke
Copy link
Contributor

🎟️ Tracking

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

📔 Objective

Refactor the subscription response model to decouple license information from subscription data, implementing proper separation of concerns between billing and licensing functionality.

Code changes

Backend Changes

New Files:
- src/Api/Models/Response/LicenseResponseModel.cs - New response model for license data
- test/Api.Test/Billing/Controllers/VNext/AccountBillingVNextControllerTests.cs - Unit tests for new license endpoint

Modified Files:
- src/Api/Models/Response/SubscriptionResponseModel.cs:
- Removed License property
- Removed Expiration property
- Removed license-related constructor parameters
- Maintained all subscription and discount functionality
- src/Api/Billing/Controllers/VNext/AccountBillingVNextController.cs:
- Added GET /account/billing/vnext/license endpoint
- Added IUserService and ILicensingService dependencies
- src/Api/Billing/Controllers/AccountsController.cs:
- Updated GetSubscriptionAsync to remove license generation
- Removed ILicensingService dependency

Test Updates:

  • Updated SubscriptionResponseModelTests.cs - Fixed 14 tests to use new constructor signatures
  • Updated AccountsControllerTests.cs - Removed licensing service mock

Breaking Changes

⚠️ API Breaking Change: The SubscriptionResponseModel no longer includes License and Expiration properties.

Migration Path:

  • Frontend clients should call GET /account/billing/vnext/license separately to retrieve license information
  • The subscription endpoint continues to return all subscription and billing data

📸 Screenshots

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 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

@cyprain-okeke cyprain-okeke requested a review from a team as a code owner December 22, 2025 10:18
@github-actions
Copy link
Contributor

github-actions bot commented Dec 22, 2025

Logo
Checkmarx One – Scan Summary & Details96a4fa27-5852-4f25-a721-63b0aa7b19d4

New Issues (5)

Checkmarx found the following issues in this Pull Request

# Severity Issue Source File / Package Checkmarx Insight
1 MEDIUM CSRF /src/Api/Vault/Controllers/CiphersController.cs: 1170
detailsMethod at line 1170 of /src/Api/Vault/Controllers/CiphersController.cs gets a parameter from a user request from id. This parameter value flows ...
Attack Vector
2 MEDIUM CSRF /src/Api/Vault/Controllers/CiphersController.cs: 1060
detailsMethod at line 1060 of /src/Api/Vault/Controllers/CiphersController.cs gets a parameter from a user request from id. This parameter value flows ...
Attack Vector
3 MEDIUM CSRF /src/Api/Auth/Controllers/AccountsController.cs: 431
detailsMethod at line 431 of /src/Api/Auth/Controllers/AccountsController.cs gets a parameter from a user request from model. This parameter value flow...
Attack Vector
4 MEDIUM CSRF /src/Api/Vault/Controllers/CiphersController.cs: 1519
detailsMethod at line 1519 of /src/Api/Vault/Controllers/CiphersController.cs gets a parameter from a user request from id. This parameter value flows ...
Attack Vector
5 MEDIUM CSRF /src/Api/Vault/Controllers/CiphersController.cs: 1395
detailsMethod at line 1395 of /src/Api/Vault/Controllers/CiphersController.cs gets a parameter from a user request from id. This parameter value flows ...
Attack Vector
Fixed Issues (1)

Great job! The following issues were fixed in this Pull Request

Severity Issue Source File / Package
MEDIUM CSRF /src/Api/Vault/Controllers/CiphersController.cs: 300

@codecov
Copy link

codecov bot commented Dec 22, 2025

Codecov Report

❌ Patch coverage is 60.00000% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.83%. Comparing base (f82552f) to head (9cec655).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...re/Billing/Licenses/Queries/GetUserLicenseQuery.cs 0.00% 8 Missing ⚠️
...censes/Models/Api/Response/LicenseResponseModel.cs 69.23% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6768      +/-   ##
==========================================
- Coverage   54.84%   54.83%   -0.01%     
==========================================
  Files        1920     1923       +3     
  Lines       85255    85285      +30     
  Branches     7633     7634       +1     
==========================================
+ Hits        46757    46770      +13     
- Misses      36718    36734      +16     
- Partials     1780     1781       +1     

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

throw new UnauthorizedAccessException();
}

var license = await userService.GenerateLicenseAsync(user);
Copy link
Contributor

Choose a reason for hiding this comment

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

⛏️ Please create a query for this logic. We'd like to keep our only controller-level dependencies for these controllers to be commands and queries. It can go in Core/Billing/Licenses like the response model.

/// you want to expose Milestone 2 discount information to the client.
/// The discount will only be included if it matches the specific Milestone 2 coupon ID.
/// </param>
public SubscriptionResponseModel(User user, SubscriptionInfo subscription, UserLicense license, bool includeMilestone2Discount = false)
Copy link
Contributor

Choose a reason for hiding this comment

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

❌ Again, we're removing something from the existing flow without flagging the change. If the FF that toggles the new Premium subscription page is not active, where is the license going to come from?

Copy link
Contributor

Choose a reason for hiding this comment

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

See comment on the AccountsController

@cyprain-okeke cyprain-okeke force-pushed the pm-29611-decouple-license-from-subscription-response branch from 628d8c2 to 7148bf2 Compare December 30, 2025 07:40
// Check if the new premium subscription page feature flag is enabled
// When enabled, clients should use the separate /license endpoint
// When disabled, include license in subscription response for backward compatibility
var useNewPremiumPage = featureService.IsEnabled(FeatureFlagKeys.PM24996ImplementUpgradeFromFreeDialog);
Copy link
Contributor

Choose a reason for hiding this comment

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

❌ There does not need to be any changes to the existing AccountsController or the SubscriptionResponseModel. This is a net-new addition of an endpoint that will service the redesigned Premium Subscription page. Once we enable the flag for the redesign, the new endpoints will be hit instead of these and at that point, we can make these changes.

/// you want to expose Milestone 2 discount information to the client.
/// The discount will only be included if it matches the specific Milestone 2 coupon ID.
/// </param>
public SubscriptionResponseModel(User user, SubscriptionInfo subscription, UserLicense license, bool includeMilestone2Discount = false)
Copy link
Contributor

Choose a reason for hiding this comment

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

See comment on the AccountsController

public async Task<IResult> GetLicenseAsync(
[BindNever] User user)
{
if (user == null)
Copy link
Contributor

Choose a reason for hiding this comment

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

❌ This check is not necessary when using InjectUser.

@cyprain-okeke cyprain-okeke merged commit 665be6b into main Dec 31, 2025
42 checks passed
@cyprain-okeke cyprain-okeke deleted the pm-29611-decouple-license-from-subscription-response branch December 31, 2025 16:30
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.

3 participants