1
0
mirror of https://github.com/bitwarden/server synced 2026-02-25 17:03:22 +00:00

feat(register): [PM-27084] Account Register Uses New Data Types - Repush (#6855)

* feat(register): [PM-27084] Account Register Uses New Data Types - Changes.

* test(register): [PM-27084] Account Register Uses New Data Types - Added tests.

* fix(register): [PM-27084] Account Register Uses New Data Types - Added constant for feature flag.
This commit is contained in:
Patrick-Pimentel-Bitwarden
2026-02-04 10:03:55 -05:00
committed by GitHub
parent 5afdfa6fd1
commit c52f2e0d09
20 changed files with 1046 additions and 63 deletions

View File

@@ -0,0 +1,33 @@
using System.ComponentModel.DataAnnotations;
using Bit.Core.Enums;
using Bit.Core.KeyManagement.Models.Data;
using Bit.Core.Utilities;
namespace Bit.Core.KeyManagement.Models.Api.Request;
public class KdfRequestModel : IValidatableObject
{
[Required]
public required KdfType KdfType { get; init; }
[Required]
public required int Iterations { get; init; }
public int? Memory { get; init; }
public int? Parallelism { get; init; }
public KdfSettings ToData()
{
return new KdfSettings
{
KdfType = KdfType,
Iterations = Iterations,
Memory = Memory,
Parallelism = Parallelism
};
}
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
// Generic per-request KDF validation for any request model embedding KdfRequestModel
return KdfSettingsValidator.Validate(ToData());
}
}

View File

@@ -0,0 +1,28 @@
using System.ComponentModel.DataAnnotations;
using Bit.Core.KeyManagement.Models.Data;
namespace Bit.Core.KeyManagement.Models.Api.Request;
/// <summary>
/// Use this datatype when interfacing with requests to create a separation of concern.
/// See <see cref="MasterPasswordAuthenticationData"/> to use for commands, queries, services.
/// </summary>
public class MasterPasswordAuthenticationDataRequestModel
{
public required KdfRequestModel Kdf { get; init; }
[Required]
public required string MasterPasswordAuthenticationHash { get; init; }
[Required]
[StringLength(256)]
public required string Salt { get; init; }
public MasterPasswordAuthenticationData ToData()
{
return new MasterPasswordAuthenticationData
{
Kdf = Kdf.ToData(),
MasterPasswordAuthenticationHash = MasterPasswordAuthenticationHash,
Salt = Salt
};
}
}

View File

@@ -0,0 +1,30 @@
using System.ComponentModel.DataAnnotations;
using Bit.Core.KeyManagement.Models.Data;
using Bit.Core.Utilities;
namespace Bit.Core.KeyManagement.Models.Api.Request;
/// <summary>
/// Use this datatype when interfacing with requests to create a separation of concern.
/// See <see cref="MasterPasswordUnlockData"/> to use for commands, queries, services.
/// </summary>
public class MasterPasswordUnlockDataRequestModel
{
public required KdfRequestModel Kdf { get; init; }
[Required]
[EncryptedString]
public required string MasterKeyWrappedUserKey { get; init; }
[Required]
[StringLength(256)]
public required string Salt { get; init; }
public MasterPasswordUnlockData ToData()
{
return new MasterPasswordUnlockData
{
Kdf = Kdf.ToData(),
MasterKeyWrappedUserKey = MasterKeyWrappedUserKey,
Salt = Salt
};
}
}

View File

@@ -1,8 +1,13 @@
using Bit.Core.Entities;
using Bit.Core.Exceptions;
using Bit.Core.KeyManagement.Models.Api.Request;
namespace Bit.Core.KeyManagement.Models.Data;
/// <summary>
/// Use this datatype when interfacing with commands, queries, services to create a separation of concern.
/// See <see cref="MasterPasswordAuthenticationDataRequestModel"/> to use for requests.
/// </summary>
public class MasterPasswordAuthenticationData
{
public required KdfSettings Kdf { get; init; }

View File

@@ -1,5 +1,4 @@
#nullable enable
using Bit.Core.Entities;
using Bit.Core.Entities;
using Bit.Core.Enums;
namespace Bit.Core.KeyManagement.Models.Data;

View File

@@ -1,8 +1,13 @@
using Bit.Core.Entities;
using Bit.Core.Exceptions;
using Bit.Core.KeyManagement.Models.Api.Request;
namespace Bit.Core.KeyManagement.Models.Data;
/// <summary>
/// Use this datatype when interfacing with commands, queries, services to create a separation of concern.
/// See <see cref="MasterPasswordUnlockDataRequestModel"/> to use for requests.
/// </summary>
public class MasterPasswordUnlockData
{
public required KdfSettings Kdf { get; init; }