From 88d5a97a8602799c63c664f4b6900584e2f16a73 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Wed, 17 Jul 2024 15:21:32 +0200 Subject: [PATCH] Fix key rotation being broken due to org ciphers being included (#4522) --- src/Api/Vault/Validators/CipherRotationValidator.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Api/Vault/Validators/CipherRotationValidator.cs b/src/Api/Vault/Validators/CipherRotationValidator.cs index d6c12b96e9..836fe6fe1a 100644 --- a/src/Api/Vault/Validators/CipherRotationValidator.cs +++ b/src/Api/Vault/Validators/CipherRotationValidator.cs @@ -28,12 +28,18 @@ public class CipherRotationValidator : IRotationValidator(); var existingCiphers = await _cipherRepository.GetManyByUserIdAsync(user.Id, UseFlexibleCollections); - if (existingCiphers == null || existingCiphers.Count == 0) + if (existingCiphers == null) { return result; } - foreach (var existing in existingCiphers) + var existingUserCiphers = existingCiphers.Where(c => c.OrganizationId == null); + if (existingUserCiphers.Count() == 0) + { + return result; + } + + foreach (var existing in existingUserCiphers) { var cipher = ciphers.FirstOrDefault(c => c.Id == existing.Id); if (cipher == null)