-
Notifications
You must be signed in to change notification settings - Fork 1.5k
feat(register): [PM-27084] Account Register Uses New Data Types #6715
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
Changes from 6 commits
6c7daa6
1535fa3
9000474
d7ddf2e
08f3acd
f47dac9
bb2ba14
7cb55eb
b33e1ac
c21d7b4
aa8e8cc
5b2edef
57f69ad
4f81d75
fac1d4b
2d9786e
cc895d0
4475649
a705ea4
227f3a0
fb54d21
b0cce70
af2f704
015d2ed
67ff0da
fc507a4
05d8cc5
e531ab1
28640d0
260b289
06bf7b8
c255e39
3aa0e4c
2111df7
65c0ac9
a5890d2
b5dadcd
9e43ca2
93c9631
f73904d
f92d7d2
6301dbf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| ๏ปฟ#nullable enable | ||
| using Bit.Core.Entities; | ||
| ๏ปฟusing Bit.Core.Entities; | ||
| using Bit.Core.Enums; | ||
| using Bit.Core.KeyManagement.Models.Data; | ||
| using Bit.Core.Utilities; | ||
|
|
||
| namespace Bit.Core.Auth.Models.Api.Request.Accounts; | ||
|
|
@@ -21,19 +21,28 @@ public class RegisterFinishRequestModel : IValidatableObject | |
| public required string Email { get; set; } | ||
| public string? EmailVerificationToken { get; set; } | ||
|
|
||
| public MasterPasswordAuthenticationData? MasterPasswordAuthenticationData { get; set; } | ||
mzieniukbw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| public MasterPasswordUnlockData? MasterPasswordUnlockData { get; set; } | ||
Patrick-Pimentel-Bitwarden marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
mzieniukbw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
mzieniukbw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // PM-28143 - Remove line below (made optional during migration to MasterPasswordUnlockData) | ||
| [StringLength(1000)] | ||
| public required string MasterPasswordHash { get; set; } | ||
| public string? MasterPasswordHash { get; set; } | ||
|
|
||
| [StringLength(50)] | ||
| public string? MasterPasswordHint { get; set; } | ||
|
|
||
| public required string UserSymmetricKey { get; set; } | ||
| // PM-28143 - Remove line below (made optional during migration to MasterPasswordUnlockData) | ||
| public string? UserSymmetricKey { get; set; } | ||
|
|
||
| public required KeysRequestModel UserAsymmetricKeys { get; set; } | ||
Patrick-Pimentel-Bitwarden marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. โน๏ธ This is outside of the scope of this PR, but fyi, for account registration V2, instead of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for sharing that knowledge, helps me understand future changes. |
||
|
|
||
| public required KdfType Kdf { get; set; } | ||
| public required int KdfIterations { get; set; } | ||
| // PM-28143 - Remove line below (made optional during migration to MasterPasswordUnlockData) | ||
| public KdfType? Kdf { get; set; } | ||
| // PM-28143 - Remove line below (made optional during migration to MasterPasswordUnlockData) | ||
| public int? KdfIterations { get; set; } | ||
| // PM-28143 - Remove line below | ||
| public int? KdfMemory { get; set; } | ||
| // PM-28143 - Remove line below | ||
| public int? KdfParallelism { get; set; } | ||
|
|
||
| public Guid? OrganizationUserId { get; set; } | ||
|
|
@@ -54,11 +63,13 @@ public User ToUser() | |
| { | ||
| Email = Email, | ||
| MasterPasswordHint = MasterPasswordHint, | ||
| Kdf = Kdf, | ||
| KdfIterations = KdfIterations, | ||
| KdfMemory = KdfMemory, | ||
| KdfParallelism = KdfParallelism, | ||
| Key = UserSymmetricKey, | ||
| Kdf = MasterPasswordUnlockData?.Kdf.KdfType ?? Kdf ?? throw new Exception("KdfType couldn't be found on either the MasterPasswordUnlockData or the Kdf property passed in."), | ||
Patrick-Pimentel-Bitwarden marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| KdfIterations = MasterPasswordUnlockData?.Kdf.Iterations ?? KdfIterations ?? throw new Exception("KdfIterations couldn't be found on either the MasterPasswordUnlockData or the KdfIterations property passed in."), | ||
Patrick-Pimentel-Bitwarden marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| KdfMemory = MasterPasswordUnlockData?.Kdf.Memory ?? KdfMemory, | ||
| KdfParallelism = MasterPasswordUnlockData?.Kdf.Parallelism ?? KdfParallelism, | ||
Patrick-Pimentel-Bitwarden marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // PM-28827 To be added when MasterPasswordSalt is added to the user column | ||
| // MasterPasswordSalt = MasterPasswordUnlockData?.Salt ?? Email.ToLower().Trim(), | ||
|
||
| Key = MasterPasswordUnlockData?.MasterKeyWrappedUserKey ?? UserSymmetricKey, | ||
| }; | ||
|
|
||
| UserAsymmetricKeys.ToUser(user); | ||
|
|
@@ -95,6 +106,28 @@ public RegisterFinishTokenType GetTokenType() | |
|
|
||
| public IEnumerable<ValidationResult> Validate(ValidationContext validationContext) | ||
| { | ||
| return KdfSettingsValidator.Validate(Kdf, KdfIterations, KdfMemory, KdfParallelism); | ||
| // PM-28143 - Remove line below | ||
| var kdf = MasterPasswordUnlockData?.Kdf.KdfType | ||
mzieniukbw marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ?? Kdf | ||
| ?? throw new Exception($"{nameof(Kdf)} not found on RequestModel"); | ||
Patrick-Pimentel-Bitwarden marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // PM-28143 - Remove line below | ||
| var kdfIterations = MasterPasswordUnlockData?.Kdf.Iterations | ||
| ?? KdfIterations | ||
| ?? throw new Exception($"{nameof(KdfIterations)} not found on RequestModel"); | ||
Patrick-Pimentel-Bitwarden marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| // PM-28143 - Remove line below | ||
| var kdfMemory = MasterPasswordUnlockData?.Kdf.Memory | ||
| ?? KdfMemory; | ||
|
|
||
| // PM-28143 - Remove line below | ||
| var kdfParallelism = MasterPasswordUnlockData?.Kdf.Parallelism | ||
| ?? KdfParallelism; | ||
|
|
||
| // PM-28143 - Remove line below in favor of using the unlock data. | ||
| return KdfSettingsValidator.Validate(kdf, kdfIterations, kdfMemory, kdfParallelism); | ||
|
|
||
| // PM-28143 - Uncomment | ||
| // return KdfSettingsValidator.Validate(MasterPasswordUnlockData); | ||
| } | ||
Patrick-Pimentel-Bitwarden marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.