mirror of
https://github.com/bitwarden/server.git
synced 2026-02-02 23:23:15 +08:00
* Add KdfMemory and KDFParallelism fields * Revise argon2 support This pull request makes the new attribues for argon2, kdfMemory and kdfParallelism optional. Furthermore it adds checks for the argon2 parametrs and improves the database migration script. * Add validation for argon2 in RegisterRequestModel * update validation messages * update sql scripts * register data protection with migration factories * add ef migrations * update kdf option validation * adjust validation * Centralize and Test KDF Validation Co-authored-by: Kyle Spearrin <kspearrin@users.noreply.github.com> Co-authored-by: Kyle Spearrin <kyle.spearrin@gmail.com> Co-authored-by: Justin Baur <19896123+justindbaur@users.noreply.github.com>
40 lines
1.1 KiB
C#
40 lines
1.1 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using Bit.Core.Entities;
|
|
using Bit.Core.Enums;
|
|
using Bit.Core.Models.Api.Request.Accounts;
|
|
using Bit.Core.Utilities;
|
|
|
|
namespace Bit.Api.Models.Request.Accounts;
|
|
|
|
public class SetKeyConnectorKeyRequestModel : IValidatableObject
|
|
{
|
|
[Required]
|
|
public string Key { get; set; }
|
|
[Required]
|
|
public KeysRequestModel Keys { get; set; }
|
|
[Required]
|
|
public KdfType Kdf { get; set; }
|
|
[Required]
|
|
public int KdfIterations { get; set; }
|
|
public int? KdfMemory { get; set; }
|
|
public int? KdfParallelism { get; set; }
|
|
[Required]
|
|
public string OrgIdentifier { get; set; }
|
|
|
|
public User ToUser(User existingUser)
|
|
{
|
|
existingUser.Kdf = Kdf;
|
|
existingUser.KdfIterations = KdfIterations;
|
|
existingUser.KdfMemory = KdfMemory;
|
|
existingUser.KdfParallelism = KdfParallelism;
|
|
existingUser.Key = Key;
|
|
Keys.ToUser(existingUser);
|
|
return existingUser;
|
|
}
|
|
|
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
|
{
|
|
return KdfSettingsValidator.Validate(Kdf, KdfIterations, KdfMemory, KdfParallelism);
|
|
}
|
|
}
|