Skip to content

Conversation

@cturnbull-bitwarden
Copy link
Contributor

🎟️ Tracking

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

📔 Objective

Fix a bug where self-hosted organizations updating their license files were not using the Token JWT as the authoritative source of truth.

The UpdateOrganizationLicenseCommand was only extracting 1 out of 42 properties from Token-based (JWT claims) licenses. The other 41 properties were read from the deserialized JSON file properties instead of the authoritative Token claims. This created an architectural inconsistency where the Token (signed by the cloud) was not the single source of truth, and stale or incorrect values in the JSON properties could override the Token claims.

This PR ensures the Token JWT is the single source of truth by extracting all organization properties from claims before validation and database update. Also fixes the same issue in user license updates and adds missing properties to SelfHostedOrganizationDetails.ToOrganization().

📸 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

@claude
Copy link
Contributor

claude bot commented Nov 5, 2025

Claude Code is working…

I'll analyze this and get back to you.

View job run

@github-actions
Copy link
Contributor

github-actions bot commented Nov 5, 2025

Logo
Checkmarx One – Scan Summary & Detailsc814977d-a2fe-428f-a4a0-9430aba27e14

Fixed Issues (1)

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

Severity Issue Source File / Package
MEDIUM CSRF /src/Api/AdminConsole/Controllers/OrganizationUsersController.cs: 511

@codecov
Copy link

codecov bot commented Nov 6, 2025

Codecov Report

❌ Patch coverage is 87.50000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 55.46%. Comparing base (e705fe3) to head (35a9845).

Files with missing lines Patch % Lines
src/Core/Services/Implementations/UserService.cs 0.00% 6 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6546      +/-   ##
==========================================
+ Coverage   55.26%   55.46%   +0.19%     
==========================================
  Files        1939     1939              
  Lines       86224    86276      +52     
  Branches     7705     7706       +1     
==========================================
+ Hits        47655    47854     +199     
+ Misses      36777    36638     -139     
+ Partials     1792     1784       -8     

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

r-tome
r-tome previously approved these changes Nov 6, 2025
Copy link
Contributor

@cyprain-okeke cyprain-okeke left a comment

Choose a reason for hiding this comment

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

Nice Work sir, Left some few comments

cturnbull-bitwarden and others added 2 commits November 11, 2025 12:19
# Conflicts:
#	src/Core/AdminConsole/Models/Data/Organizations/SelfHostedOrganizationDetails.cs
#	test/Core.Test/Billing/Organizations/Commands/UpdateOrganizationLicenseCommandTests.cs
r-tome
r-tome previously approved these changes Jan 8, 2026
Copy link
Contributor

@cyprain-okeke cyprain-okeke left a comment

Choose a reason for hiding this comment

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

Looks Nice!

license.UseOrganizationDomains = claimsPrincipal.GetValue<bool>(OrganizationLicenseConstants.UseOrganizationDomains);
license.UseAdminSponsoredFamilies = claimsPrincipal.GetValue<bool>(OrganizationLicenseConstants.UseAdminSponsoredFamilies);
license.UseAutomaticUserConfirmation = claimsPrincipal.GetValue<bool>(OrganizationLicenseConstants.UseAutomaticUserConfirmation);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The code extracts 29 properties, but two constants appear to be missing from OrganizationLicenseConstants:

  • UseDisableSmAdsForUsers
  • UsePhishingBlocker. Is this intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, it wasn't. Those two seem to be new additions from when I opened this PR. I'll get them added, good catch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch @cyprain-okeke , I just pushed a commit addressing this. I also added a set of unit tests to guide future developers through the process of adding a property to the organization license

Copy link
Contributor

@cyprain-okeke cyprain-okeke left a comment

Choose a reason for hiding this comment

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

Thanks for adding the properties

Copy link
Contributor

@r-tome r-tome left a comment

Choose a reason for hiding this comment

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

Great work, using reflection is smart!

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.

4 participants