From 1ef37fb248a6e9efc679ef9f2e6376e1dbb5c6aa Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Fri, 25 Oct 2024 11:41:37 +0200 Subject: [PATCH] Move key rotation & validators to km ownership --- src/Api/Auth/Controllers/AccountsController.cs | 2 +- .../Validators/CipherRotationValidator.cs | 5 ++--- .../Validators/EmergencyAccessRotationValidator.cs | 2 +- .../Validators/FolderRotationValidator.cs | 5 ++--- .../{Auth => KeyManagement}/Validators/IRotationValidator.cs | 2 +- .../Validators/OrganizationUserRotationValidator.cs | 3 +-- .../Validators/SendRotationValidator.cs | 5 ++--- .../Validators/WebAuthnLoginKeyRotationValidator.cs | 2 +- src/Api/Startup.cs | 5 +---- .../UserKey/IRotateUserKeyCommand.cs | 0 .../UserKey/Implementations/RotateUserKeyCommand.cs | 0 test/Api.Test/Auth/Controllers/AccountsControllerTests.cs | 2 +- .../Validators/CipherRotationValidatorTests.cs | 0 .../Validators/EmergencyAccessRotationValidatorTests.cs | 4 ++-- .../Validators/FolderRotationValidatorTests.cs | 4 ++-- .../Validators/OrganizationUserRotationValidatorTests.cs | 4 ++-- .../Validators/SendRotationValidatorTests.cs | 0 .../Validators/WebauthnLoginKeyRotationValidatorTests.cs | 2 +- 18 files changed, 20 insertions(+), 27 deletions(-) rename src/Api/{Vault => KeyManagement}/Validators/CipherRotationValidator.cs (92%) rename src/Api/{Auth => KeyManagement}/Validators/EmergencyAccessRotationValidator.cs (97%) rename src/Api/{Vault => KeyManagement}/Validators/FolderRotationValidator.cs (91%) rename src/Api/{Auth => KeyManagement}/Validators/IRotationValidator.cs (94%) rename src/Api/{AdminConsole => KeyManagement}/Validators/OrganizationUserRotationValidator.cs (96%) rename src/Api/{Tools => KeyManagement}/Validators/SendRotationValidator.cs (94%) rename src/Api/{Auth => KeyManagement}/Validators/WebAuthnLoginKeyRotationValidator.cs (97%) rename src/Core/{Auth/UserFeatures => KeyManagement}/UserKey/IRotateUserKeyCommand.cs (100%) rename src/Core/{Auth/UserFeatures => KeyManagement}/UserKey/Implementations/RotateUserKeyCommand.cs (100%) rename test/Api.Test/{Vault => KeyManagement}/Validators/CipherRotationValidatorTests.cs (100%) rename test/Api.Test/{Auth => KeyManagement}/Validators/EmergencyAccessRotationValidatorTests.cs (98%) rename test/Api.Test/{Vault => KeyManagement}/Validators/FolderRotationValidatorTests.cs (96%) rename test/Api.Test/{AdminConsole => KeyManagement}/Validators/OrganizationUserRotationValidatorTests.cs (98%) rename test/Api.Test/{Tools => KeyManagement}/Validators/SendRotationValidatorTests.cs (100%) rename test/Api.Test/{Auth => KeyManagement}/Validators/WebauthnLoginKeyRotationValidatorTests.cs (98%) diff --git a/src/Api/Auth/Controllers/AccountsController.cs b/src/Api/Auth/Controllers/AccountsController.cs index a0c01752a..e08e6b3b0 100644 --- a/src/Api/Auth/Controllers/AccountsController.cs +++ b/src/Api/Auth/Controllers/AccountsController.cs @@ -3,7 +3,7 @@ using Bit.Api.AdminConsole.Models.Response; using Bit.Api.Auth.Models.Request; using Bit.Api.Auth.Models.Request.Accounts; using Bit.Api.Auth.Models.Request.WebAuthn; -using Bit.Api.Auth.Validators; +using Bit.Api.KeyManagement.Validators; using Bit.Api.Models.Request; using Bit.Api.Models.Request.Accounts; using Bit.Api.Models.Response; diff --git a/src/Api/Vault/Validators/CipherRotationValidator.cs b/src/Api/KeyManagement/Validators/CipherRotationValidator.cs similarity index 92% rename from src/Api/Vault/Validators/CipherRotationValidator.cs rename to src/Api/KeyManagement/Validators/CipherRotationValidator.cs index 77e437017..ab56db419 100644 --- a/src/Api/Vault/Validators/CipherRotationValidator.cs +++ b/src/Api/KeyManagement/Validators/CipherRotationValidator.cs @@ -1,11 +1,10 @@ -using Bit.Api.Auth.Validators; -using Bit.Api.Vault.Models.Request; +using Bit.Api.Vault.Models.Request; using Bit.Core.Entities; using Bit.Core.Exceptions; using Bit.Core.Vault.Entities; using Bit.Core.Vault.Repositories; -namespace Bit.Api.Vault.Validators; +namespace Bit.Api.KeyManagement.Validators; public class CipherRotationValidator : IRotationValidator, IEnumerable> { diff --git a/src/Api/Auth/Validators/EmergencyAccessRotationValidator.cs b/src/Api/KeyManagement/Validators/EmergencyAccessRotationValidator.cs similarity index 97% rename from src/Api/Auth/Validators/EmergencyAccessRotationValidator.cs rename to src/Api/KeyManagement/Validators/EmergencyAccessRotationValidator.cs index 5a038730e..3fd9273e4 100644 --- a/src/Api/Auth/Validators/EmergencyAccessRotationValidator.cs +++ b/src/Api/KeyManagement/Validators/EmergencyAccessRotationValidator.cs @@ -5,7 +5,7 @@ using Bit.Core.Exceptions; using Bit.Core.Repositories; using Bit.Core.Services; -namespace Bit.Api.Auth.Validators; +namespace Bit.Api.KeyManagement.Validators; public class EmergencyAccessRotationValidator : IRotationValidator, IEnumerable> diff --git a/src/Api/Vault/Validators/FolderRotationValidator.cs b/src/Api/KeyManagement/Validators/FolderRotationValidator.cs similarity index 91% rename from src/Api/Vault/Validators/FolderRotationValidator.cs rename to src/Api/KeyManagement/Validators/FolderRotationValidator.cs index 4290c08b1..add0a46c1 100644 --- a/src/Api/Vault/Validators/FolderRotationValidator.cs +++ b/src/Api/KeyManagement/Validators/FolderRotationValidator.cs @@ -1,11 +1,10 @@ -using Bit.Api.Auth.Validators; -using Bit.Api.Vault.Models.Request; +using Bit.Api.Vault.Models.Request; using Bit.Core.Entities; using Bit.Core.Exceptions; using Bit.Core.Vault.Entities; using Bit.Core.Vault.Repositories; -namespace Bit.Api.Vault.Validators; +namespace Bit.Api.KeyManagement.Validators; public class FolderRotationValidator : IRotationValidator, IEnumerable> { diff --git a/src/Api/Auth/Validators/IRotationValidator.cs b/src/Api/KeyManagement/Validators/IRotationValidator.cs similarity index 94% rename from src/Api/Auth/Validators/IRotationValidator.cs rename to src/Api/KeyManagement/Validators/IRotationValidator.cs index fb6534ebe..50f4dd004 100644 --- a/src/Api/Auth/Validators/IRotationValidator.cs +++ b/src/Api/KeyManagement/Validators/IRotationValidator.cs @@ -1,7 +1,7 @@ using Bit.Core.Entities; using Bit.Core.Exceptions; -namespace Bit.Api.Auth.Validators; +namespace Bit.Api.KeyManagement.Validators; /// /// A consistent interface for domains to validate re-encrypted data before saved to database. Some examples are:
diff --git a/src/Api/AdminConsole/Validators/OrganizationUserRotationValidator.cs b/src/Api/KeyManagement/Validators/OrganizationUserRotationValidator.cs similarity index 96% rename from src/Api/AdminConsole/Validators/OrganizationUserRotationValidator.cs rename to src/Api/KeyManagement/Validators/OrganizationUserRotationValidator.cs index c9cf39ae0..5023521fe 100644 --- a/src/Api/AdminConsole/Validators/OrganizationUserRotationValidator.cs +++ b/src/Api/KeyManagement/Validators/OrganizationUserRotationValidator.cs @@ -1,10 +1,9 @@ using Bit.Api.AdminConsole.Models.Request.Organizations; -using Bit.Api.Auth.Validators; using Bit.Core.Entities; using Bit.Core.Exceptions; using Bit.Core.Repositories; -namespace Bit.Api.AdminConsole.Validators; +namespace Bit.Api.KeyManagement.Validators; /// /// Organization user implementation for diff --git a/src/Api/Tools/Validators/SendRotationValidator.cs b/src/Api/KeyManagement/Validators/SendRotationValidator.cs similarity index 94% rename from src/Api/Tools/Validators/SendRotationValidator.cs rename to src/Api/KeyManagement/Validators/SendRotationValidator.cs index 74b36832f..c39f563b5 100644 --- a/src/Api/Tools/Validators/SendRotationValidator.cs +++ b/src/Api/KeyManagement/Validators/SendRotationValidator.cs @@ -1,12 +1,11 @@ -using Bit.Api.Auth.Validators; -using Bit.Api.Tools.Models.Request; +using Bit.Api.Tools.Models.Request; using Bit.Core.Entities; using Bit.Core.Exceptions; using Bit.Core.Tools.Entities; using Bit.Core.Tools.Repositories; using Bit.Core.Tools.Services; -namespace Bit.Api.Tools.Validators; +namespace Bit.Api.KeyManagement.Validators; /// /// Send implementation for diff --git a/src/Api/Auth/Validators/WebAuthnLoginKeyRotationValidator.cs b/src/Api/KeyManagement/Validators/WebAuthnLoginKeyRotationValidator.cs similarity index 97% rename from src/Api/Auth/Validators/WebAuthnLoginKeyRotationValidator.cs rename to src/Api/KeyManagement/Validators/WebAuthnLoginKeyRotationValidator.cs index 5c4d0ef30..1706aebd7 100644 --- a/src/Api/Auth/Validators/WebAuthnLoginKeyRotationValidator.cs +++ b/src/Api/KeyManagement/Validators/WebAuthnLoginKeyRotationValidator.cs @@ -4,7 +4,7 @@ using Bit.Core.Auth.Repositories; using Bit.Core.Entities; using Bit.Core.Exceptions; -namespace Bit.Api.Auth.Validators; +namespace Bit.Api.KeyManagement.Validators; public class WebAuthnLoginKeyRotationValidator : IRotationValidator, IEnumerable> { diff --git a/src/Api/Startup.cs b/src/Api/Startup.cs index 8a7721bcb..e5a797758 100644 --- a/src/Api/Startup.cs +++ b/src/Api/Startup.cs @@ -8,13 +8,10 @@ using Bit.Core.Utilities; using IdentityModel; using System.Globalization; using Bit.Api.AdminConsole.Models.Request.Organizations; -using Bit.Api.AdminConsole.Validators; using Bit.Api.Auth.Models.Request; -using Bit.Api.Auth.Validators; +using Bit.Api.KeyManagement.Validators; using Bit.Api.Tools.Models.Request; -using Bit.Api.Tools.Validators; using Bit.Api.Vault.Models.Request; -using Bit.Api.Vault.Validators; using Bit.Core.Auth.Entities; using Bit.Core.IdentityServer; using Bit.SharedWeb.Health; diff --git a/src/Core/Auth/UserFeatures/UserKey/IRotateUserKeyCommand.cs b/src/Core/KeyManagement/UserKey/IRotateUserKeyCommand.cs similarity index 100% rename from src/Core/Auth/UserFeatures/UserKey/IRotateUserKeyCommand.cs rename to src/Core/KeyManagement/UserKey/IRotateUserKeyCommand.cs diff --git a/src/Core/Auth/UserFeatures/UserKey/Implementations/RotateUserKeyCommand.cs b/src/Core/KeyManagement/UserKey/Implementations/RotateUserKeyCommand.cs similarity index 100% rename from src/Core/Auth/UserFeatures/UserKey/Implementations/RotateUserKeyCommand.cs rename to src/Core/KeyManagement/UserKey/Implementations/RotateUserKeyCommand.cs diff --git a/test/Api.Test/Auth/Controllers/AccountsControllerTests.cs b/test/Api.Test/Auth/Controllers/AccountsControllerTests.cs index a16a9cb55..4175fd002 100644 --- a/test/Api.Test/Auth/Controllers/AccountsControllerTests.cs +++ b/test/Api.Test/Auth/Controllers/AccountsControllerTests.cs @@ -4,7 +4,7 @@ using Bit.Api.Auth.Controllers; using Bit.Api.Auth.Models.Request; using Bit.Api.Auth.Models.Request.Accounts; using Bit.Api.Auth.Models.Request.WebAuthn; -using Bit.Api.Auth.Validators; +using Bit.Api.KeyManagement.Validators; using Bit.Api.Tools.Models.Request; using Bit.Api.Vault.Models.Request; using Bit.Core.AdminConsole.Repositories; diff --git a/test/Api.Test/Vault/Validators/CipherRotationValidatorTests.cs b/test/Api.Test/KeyManagement/Validators/CipherRotationValidatorTests.cs similarity index 100% rename from test/Api.Test/Vault/Validators/CipherRotationValidatorTests.cs rename to test/Api.Test/KeyManagement/Validators/CipherRotationValidatorTests.cs diff --git a/test/Api.Test/Auth/Validators/EmergencyAccessRotationValidatorTests.cs b/test/Api.Test/KeyManagement/Validators/EmergencyAccessRotationValidatorTests.cs similarity index 98% rename from test/Api.Test/Auth/Validators/EmergencyAccessRotationValidatorTests.cs rename to test/Api.Test/KeyManagement/Validators/EmergencyAccessRotationValidatorTests.cs index c75ccd643..e00129fd8 100644 --- a/test/Api.Test/Auth/Validators/EmergencyAccessRotationValidatorTests.cs +++ b/test/Api.Test/KeyManagement/Validators/EmergencyAccessRotationValidatorTests.cs @@ -1,5 +1,5 @@ using Bit.Api.Auth.Models.Request; -using Bit.Api.Auth.Validators; +using Bit.Api.KeyManagement.Validators; using Bit.Core.Auth.Models.Data; using Bit.Core.Entities; using Bit.Core.Exceptions; @@ -10,7 +10,7 @@ using Bit.Test.Common.AutoFixture.Attributes; using NSubstitute; using Xunit; -namespace Bit.Api.Test.Auth.Validators; +namespace Bit.Api.Test.KeyManagement.Validators; [SutProviderCustomize] public class EmergencyAccessRotationValidatorTests diff --git a/test/Api.Test/Vault/Validators/FolderRotationValidatorTests.cs b/test/Api.Test/KeyManagement/Validators/FolderRotationValidatorTests.cs similarity index 96% rename from test/Api.Test/Vault/Validators/FolderRotationValidatorTests.cs rename to test/Api.Test/KeyManagement/Validators/FolderRotationValidatorTests.cs index 0888fd32d..94d332868 100644 --- a/test/Api.Test/Vault/Validators/FolderRotationValidatorTests.cs +++ b/test/Api.Test/KeyManagement/Validators/FolderRotationValidatorTests.cs @@ -1,5 +1,5 @@ using Bit.Api.Vault.Models.Request; -using Bit.Api.Vault.Validators; +using Bit.Api.KeyManagement.Validators; using Bit.Core.Entities; using Bit.Core.Exceptions; using Bit.Core.Vault.Entities; @@ -9,7 +9,7 @@ using Bit.Test.Common.AutoFixture.Attributes; using NSubstitute; using Xunit; -namespace Bit.Api.Test.Vault.Validators; +namespace Bit.Api.Test.KeyManagement.Validators; [SutProviderCustomize] public class FolderRotationValidatorTests diff --git a/test/Api.Test/AdminConsole/Validators/OrganizationUserRotationValidatorTests.cs b/test/Api.Test/KeyManagement/Validators/OrganizationUserRotationValidatorTests.cs similarity index 98% rename from test/Api.Test/AdminConsole/Validators/OrganizationUserRotationValidatorTests.cs rename to test/Api.Test/KeyManagement/Validators/OrganizationUserRotationValidatorTests.cs index 5d4ffeef6..964c80190 100644 --- a/test/Api.Test/AdminConsole/Validators/OrganizationUserRotationValidatorTests.cs +++ b/test/Api.Test/KeyManagement/Validators/OrganizationUserRotationValidatorTests.cs @@ -1,5 +1,5 @@ using Bit.Api.AdminConsole.Models.Request.Organizations; -using Bit.Api.AdminConsole.Validators; +using Bit.Api.KeyManagement.Validators; using Bit.Core.Entities; using Bit.Core.Exceptions; using Bit.Core.Repositories; @@ -8,7 +8,7 @@ using Bit.Test.Common.AutoFixture.Attributes; using NSubstitute; using Xunit; -namespace Bit.Api.Test.AdminConsole.Validators; +namespace Bit.Api.Test.KeyManagement.Validators; [SutProviderCustomize] public class OrganizationUserRotationValidatorTests diff --git a/test/Api.Test/Tools/Validators/SendRotationValidatorTests.cs b/test/Api.Test/KeyManagement/Validators/SendRotationValidatorTests.cs similarity index 100% rename from test/Api.Test/Tools/Validators/SendRotationValidatorTests.cs rename to test/Api.Test/KeyManagement/Validators/SendRotationValidatorTests.cs diff --git a/test/Api.Test/Auth/Validators/WebauthnLoginKeyRotationValidatorTests.cs b/test/Api.Test/KeyManagement/Validators/WebauthnLoginKeyRotationValidatorTests.cs similarity index 98% rename from test/Api.Test/Auth/Validators/WebauthnLoginKeyRotationValidatorTests.cs rename to test/Api.Test/KeyManagement/Validators/WebauthnLoginKeyRotationValidatorTests.cs index 97eadcbdc..193024a58 100644 --- a/test/Api.Test/Auth/Validators/WebauthnLoginKeyRotationValidatorTests.cs +++ b/test/Api.Test/KeyManagement/Validators/WebauthnLoginKeyRotationValidatorTests.cs @@ -1,5 +1,5 @@ using Bit.Api.Auth.Models.Request.WebAuthn; -using Bit.Api.Auth.Validators; +using Bit.Api.KeyManagement.Validators; using Bit.Core.Auth.Entities; using Bit.Core.Auth.Repositories; using Bit.Core.Entities;