-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[PM-29556] Fix: changing organization plan nulls out public and private keys #6738
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
Merged
eliykat
merged 12 commits into
main
from
ac/pm-29556/server-changing-organization-plan-nulls-out-public-and-private-keys
Dec 26, 2025
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2acbb9b
Initial fix
eliykat 8f46e72
remove duplicate assignments
eliykat 3c16b3e
Misc tweaks
eliykat 261c40a
Use method to map between api and core
eliykat 4adb96b
Ensure keys are set together or not at all
eliykat 78fe901
Tweak comment
eliykat 184cbb7
Use KM Team keypair model
eliykat 823bf6a
Tweak tests
eliykat 74cefb7
Merge remote-tracking branch 'origin/main' into ac/pm-29556/server-chโฆ
eliykat 449d4d1
dotnet format
eliykat 8b78356
Merge branch 'main' into ac/pm-29556/server-changing-organization-plaโฆ
eliykat 5ee3e0d
Merge branch 'main' into ac/pm-29556/server-changing-organization-plaโฆ
eliykat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/Core/AdminConsole/OrganizationFeatures/Organizations/OrganizationExtensions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| ๏ปฟusing Bit.Core.AdminConsole.Entities; | ||
| using Bit.Core.KeyManagement.Models.Data; | ||
|
|
||
| namespace Bit.Core.AdminConsole.OrganizationFeatures.Organizations; | ||
|
|
||
| public static class OrganizationExtensions | ||
| { | ||
| /// <summary> | ||
| /// Updates the organization public and private keys if provided and not already set. | ||
| /// This is legacy code for old organizations that were not created with a public/private keypair. | ||
| /// It is a soft migration that will silently migrate organizations when they perform certain actions, | ||
| /// e.g. change their details or upgrade their plan. | ||
| /// </summary> | ||
| public static void BackfillPublicPrivateKeys(this Organization organization, PublicKeyEncryptionKeyPairData? keyPair) | ||
| { | ||
| // Only backfill if both new keys are provided and both old keys are missing. | ||
| if (string.IsNullOrWhiteSpace(keyPair?.PublicKey) || | ||
| string.IsNullOrWhiteSpace(keyPair.WrappedPrivateKey) || | ||
| !string.IsNullOrWhiteSpace(organization.PublicKey) || | ||
| !string.IsNullOrWhiteSpace(organization.PrivateKey)) | ||
| { | ||
| return; | ||
| } | ||
|
|
||
| organization.PublicKey = keyPair.PublicKey; | ||
| organization.PrivateKey = keyPair.WrappedPrivateKey; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 0 additions & 43 deletions
43
...re/AdminConsole/OrganizationFeatures/Organizations/Update/OrganizationUpdateExtensions.cs
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Unrelated fix: remove duplicate property assignments.