[PM-39455] Set Upgrade Tokens for Organizations - #8158
Conversation
Add OrganizationUser.V2UpgradeToken and write it during a V1 to V2 upgrade rotation, so an organization admin can unwrap the V2 user key through account recovery and update the account recovery key without prompting the member. A manual rotation always logs the user out, so it never persists a token and clears any token left over from an earlier upgrade.
ce7d47f to
bc9a62a
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8158 +/- ##
===========================================
+ Coverage 15.10% 67.53% +52.42%
===========================================
Files 1417 2315 +898
Lines 61422 100520 +39098
Branches 4901 9044 +4143
===========================================
+ Hits 9279 67885 +58606
+ Misses 51978 30350 -21628
- Partials 165 2285 +2120 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE Reviewed the addition of Code Review Details
|
| [RevocationReason] TINYINT NULL, | ||
| [StatusNew] SMALLINT NULL, | ||
| [AccessPam] BIT NOT NULL CONSTRAINT [DF_OrganizationUser_Pam] DEFAULT (0), | ||
| [V2UpgradeToken] VARCHAR (MAX) NULL, |
There was a problem hiding this comment.
I understand the V2 prefix is for versioning, but database columns are much harder to change than application code. Are there plans to rename this column after the migration is complete? If so, can we look into a strategy to avoid having to rename it?
There was a problem hiding this comment.
When user rotates their keys (as part of forced user encryption v2 rollout), we fill in this column with value, where later organization (admin/owner) would upgrade the user's account recovery to new keys.
V2 in this context means that for a user with encryption v2 (v2 user keys), there is an upgrade token, that can be used to grab the v1 user key and migrate the organization member account recovery to use v2 user key - since account recovery holds sealed user key.
Once migrated, we NULL the value.
After ~1 year we will drop the column out of existence with it's value - this will be after we rollout forced user encryption v2), so likely this column will be gone in 2027-28
There was a problem hiding this comment.
Note, we already have the same on User table, https://github.com/bitwarden/server/blob/main/src/Sql/dbo/Tables/User.sql#L49 but it have different use and lifecycle, hence have to be duplicated into OrganizationUser table.
JimmyVo16
left a comment
There was a problem hiding this comment.
Just one question about the database column naming. DBOps will probably have a stronger opinion on the topic, but other than that, it looks good from the AC side.
🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-39455
📔 Objective
Add
OrganizationUser.V2UpgradeTokenand write it during a V1 to V2 upgrade rotation, so an organization admin can unwrap the V2 user key through account recovery and update the account recovery key without prompting the member (tackled separately in later PRs).A manual rotation always logs the user out, so it never persists a token and clears any token left over from an earlier upgrade.
📸 Screenshots