2021-10-25 15:09:14 +02:00
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
2023-04-14 13:25:56 -04:00
|
|
|
|
using Bit.Core.Auth.Models.Api.Request.Accounts;
|
2022-01-11 10:40:51 +01:00
|
|
|
|
using Bit.Core.Entities;
|
2021-10-25 15:09:14 +02:00
|
|
|
|
using Bit.Core.Enums;
|
2023-01-25 13:56:54 +01:00
|
|
|
|
using Bit.Core.Utilities;
|
2021-10-25 15:09:14 +02:00
|
|
|
|
|
2023-04-14 13:25:56 -04:00
|
|
|
|
namespace Bit.Api.Auth.Models.Request.Accounts;
|
2022-08-29 16:06:55 -04:00
|
|
|
|
|
2023-01-25 13:56:54 +01:00
|
|
|
|
public class SetKeyConnectorKeyRequestModel : IValidatableObject
|
2021-10-25 15:09:14 +02:00
|
|
|
|
{
|
|
|
|
|
|
[Required]
|
|
|
|
|
|
public string Key { get; set; }
|
|
|
|
|
|
[Required]
|
2021-12-14 15:05:07 +00:00
|
|
|
|
public KeysRequestModel Keys { get; set; }
|
2021-10-25 15:09:14 +02:00
|
|
|
|
[Required]
|
|
|
|
|
|
public KdfType Kdf { get; set; }
|
|
|
|
|
|
[Required]
|
|
|
|
|
|
public int KdfIterations { get; set; }
|
2023-01-25 13:56:54 +01:00
|
|
|
|
public int? KdfMemory { get; set; }
|
|
|
|
|
|
public int? KdfParallelism { get; set; }
|
2021-10-25 15:09:14 +02:00
|
|
|
|
[Required]
|
|
|
|
|
|
public string OrgIdentifier { get; set; }
|
2022-08-29 15:53:48 -04:00
|
|
|
|
|
2021-10-25 15:09:14 +02:00
|
|
|
|
public User ToUser(User existingUser)
|
2022-08-29 15:53:48 -04:00
|
|
|
|
{
|
2021-10-25 15:09:14 +02:00
|
|
|
|
existingUser.Kdf = Kdf;
|
|
|
|
|
|
existingUser.KdfIterations = KdfIterations;
|
2023-01-25 13:56:54 +01:00
|
|
|
|
existingUser.KdfMemory = KdfMemory;
|
|
|
|
|
|
existingUser.KdfParallelism = KdfParallelism;
|
2021-10-25 15:09:14 +02:00
|
|
|
|
existingUser.Key = Key;
|
|
|
|
|
|
Keys.ToUser(existingUser);
|
|
|
|
|
|
return existingUser;
|
|
|
|
|
|
}
|
2023-01-25 13:56:54 +01:00
|
|
|
|
|
|
|
|
|
|
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
|
|
|
|
|
|
{
|
|
|
|
|
|
return KdfSettingsValidator.Validate(Kdf, KdfIterations, KdfMemory, KdfParallelism);
|
|
|
|
|
|
}
|
2021-10-25 15:09:14 +02:00
|
|
|
|
}
|