-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[PM-31052] User V2UpgradeToken for key rotation without logout #6995
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
Open
mzieniukbw
wants to merge
6
commits into
main
Choose a base branch
from
km/pm-31052-upgrade-token-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
44a9dd9
User V2UpgradeToken for key rotation without logout
mzieniukbw d303b13
reset old v2 upgrade token on manual key rotation
mzieniukbw a4feee1
sql migration fix
mzieniukbw de4a673
missing table column
mzieniukbw e99bb17
missing view update
mzieniukbw 14bcba3
tests for V2UpgradeToken clearing on manual key rotation
mzieniukbw 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
35 changes: 35 additions & 0 deletions
35
src/Api/KeyManagement/Models/Requests/V2UpgradeTokenRequestModel.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,35 @@ | ||
| ο»Ώusing System.ComponentModel.DataAnnotations; | ||
| using Bit.Core.KeyManagement.Models.Data; | ||
| using Bit.Core.Utilities; | ||
|
|
||
| namespace Bit.Api.KeyManagement.Models.Requests; | ||
|
|
||
| /// <summary> | ||
| /// Request model for V2 upgrade token submitted during key rotation. | ||
| /// Contains wrapped user keys allowing clients to unlock after V1βV2 upgrade. | ||
| /// </summary> | ||
| public class V2UpgradeTokenRequestModel | ||
| { | ||
| /// <summary> | ||
| /// User Key V2 Wrapped User Key V1. | ||
| /// </summary> | ||
| [Required] | ||
| [EncryptedString] | ||
| public required string WrappedUserKey1 { get; init; } | ||
|
|
||
| /// <summary> | ||
| /// User Key V1 Wrapped User Key V2. | ||
| /// </summary> | ||
| [Required] | ||
| [EncryptedString] | ||
| public required string WrappedUserKey2 { get; init; } | ||
|
|
||
| public V2UpgradeTokenData ToData() | ||
| { | ||
| return new V2UpgradeTokenData | ||
| { | ||
| WrappedUserKey1 = WrappedUserKey1, | ||
| WrappedUserKey2 = WrappedUserKey2 | ||
| }; | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,5 +2,6 @@ | |
|
|
||
| public enum PushNotificationLogOutReason : byte | ||
| { | ||
| KdfChange = 0 | ||
| KdfChange = 0, | ||
| KeyRotation = 1 | ||
| } | ||
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
7 changes: 7 additions & 0 deletions
7
src/Core/KeyManagement/Models/Api/Response/V2UpgradeTokenResponseModel.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,7 @@ | ||
| ο»Ώnamespace Bit.Core.KeyManagement.Models.Api.Response; | ||
|
|
||
| public class V2UpgradeTokenResponseModel | ||
| { | ||
| public required string WrappedUserKey1 { get; set; } | ||
| public required string WrappedUserKey2 { get; set; } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| ο»Ώusing System.Text.Json; | ||
|
|
||
| namespace Bit.Core.KeyManagement.Models.Data; | ||
|
|
||
| public class V2UpgradeTokenData | ||
| { | ||
| public required string WrappedUserKey1 { get; init; } | ||
| public required string WrappedUserKey2 { get; init; } | ||
|
|
||
| public string ToJson() | ||
| { | ||
| return JsonSerializer.Serialize(this); | ||
| } | ||
|
|
||
| public static V2UpgradeTokenData? FromJson(string? json) | ||
| { | ||
| if (string.IsNullOrWhiteSpace(json)) | ||
| { | ||
| return null; | ||
| } | ||
|
|
||
| try | ||
| { | ||
| return JsonSerializer.Deserialize<V2UpgradeTokenData>(json); | ||
| } | ||
| catch (JsonException) | ||
| { | ||
| return null; | ||
| } | ||
| } | ||
| } |
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
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.
Oof. Makes me wonder if we should QA V2 rotations on EF separately?