mirror of
https://github.com/bitwarden/server
synced 2025-12-31 07:33:43 +00:00
[PM-29017] - improve logic for cipher SaveDetailsAsync validation (#6731)
* improve logic for cipher SaveDetailsAsync validation. fix tests * revert change * fix test * remove duplicate semicolon
This commit is contained in:
@@ -1029,11 +1029,8 @@ public class CipherService : ICipherService
|
||||
var existingCipherData = DeserializeCipherData(existingCipher);
|
||||
var newCipherData = DeserializeCipherData(cipher);
|
||||
|
||||
// "hidden password" users may not add cipher key encryption
|
||||
if (existingCipher.Key == null && cipher.Key != null)
|
||||
{
|
||||
throw new BadRequestException("You do not have permission to add cipher key encryption.");
|
||||
}
|
||||
// For hidden-password users, never allow Key to change at all.
|
||||
cipher.Key = existingCipher.Key;
|
||||
// Keep only non-hidden fileds from the new cipher
|
||||
var nonHiddenFields = newCipherData.Fields?.Where(f => f.Type != FieldType.Hidden) ?? [];
|
||||
// Get hidden fields from the existing cipher
|
||||
|
||||
Reference in New Issue
Block a user