1
0
mirror of https://github.com/bitwarden/server synced 2026-02-05 19:23:25 +00:00

fix(register): [PM-27084] Account Register Uses New Data Types - Added more validation around the master password kdf.

This commit is contained in:
Patrick Pimentel
2026-01-02 12:21:04 -05:00
parent 06bf7b82cc
commit c255e397c0

View File

@@ -192,14 +192,23 @@ public class RegisterFinishRequestModel : IValidatableObject
}
// 2. Validate kdf settings.
if (MasterPasswordUnlock != null && MasterPasswordAuthentication != null)
if (MasterPasswordUnlock != null)
{
foreach (var validationResult in KdfSettingsValidator.Validate(MasterPasswordUnlock.ToData().Kdf))
{
yield return validationResult;
}
}
else
if (MasterPasswordAuthentication != null)
{
foreach (var validationResult in KdfSettingsValidator.Validate(MasterPasswordAuthentication.ToData().Kdf))
{
yield return validationResult;
}
}
if (MasterPasswordUnlock == null && MasterPasswordAuthentication == null)
{
var hasMissingRequiredKdfInputs = false;
if (Kdf == null)
@@ -225,5 +234,15 @@ public class RegisterFinishRequestModel : IValidatableObject
}
}
}
else if (MasterPasswordUnlock == null && MasterPasswordAuthentication != null)
{
// Authentication provided but Unlock missing
yield return new ValidationResult($"{nameof(MasterPasswordUnlock)} not found on RequestModel", [nameof(MasterPasswordUnlock)]);
}
else if (MasterPasswordUnlock != null && MasterPasswordAuthentication == null)
{
// Unlock provided but Authentication missing
yield return new ValidationResult($"{nameof(MasterPasswordAuthentication)} not found on RequestModel", [nameof(MasterPasswordAuthentication)]);
}
}
}