From b85f32c35e9796be4b728ea451613f33ac66f88c Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Wed, 4 Oct 2023 23:45:21 +0200 Subject: [PATCH] [PM-4054] Rename Fido2Key to Fido2Credential (#3306) --- src/Api/Vault/Controllers/CiphersController.cs | 2 +- ...KeyModel.cs => CipherFido2CredentialModel.cs} | 16 ++++++++-------- src/Api/Vault/Models/CipherLoginModel.cs | 6 +++--- .../Vault/Models/Request/CipherRequestModel.cs | 2 +- .../Vault/Models/Response/CipherResponseModel.cs | 1 - src/Core/Vault/Models/Data/CipherLoginData.cs | 2 +- ...Data.cs => CipherLoginFido2CredentialData.cs} | 4 ++-- 7 files changed, 16 insertions(+), 17 deletions(-) rename src/Api/Vault/Models/{CipherFido2KeyModel.cs => CipherFido2CredentialModel.cs} (80%) rename src/Core/Vault/Models/Data/{CipherLoginFido2KeyData.cs => CipherLoginFido2CredentialData.cs} (85%) diff --git a/src/Api/Vault/Controllers/CiphersController.cs b/src/Api/Vault/Controllers/CiphersController.cs index 70e410328917..8e4c24dd5792 100644 --- a/src/Api/Vault/Controllers/CiphersController.cs +++ b/src/Api/Vault/Controllers/CiphersController.cs @@ -194,7 +194,7 @@ public async Task Put(Guid id, [FromBody] CipherRequestMode // Temporary protection against old clients overwriting and deleting Fido2Keys // Response model used to re-use logic for parsing 'data' property var cipherModel = new CipherResponseModel(cipher, _globalSettings); - if (cipherModel.Login?.Fido2Keys != null && _currentContext.ClientVersion < _fido2KeyCipherMinimumVersion) + if (cipherModel.Login?.Fido2Credentials != null && _currentContext.ClientVersion < _fido2KeyCipherMinimumVersion) { throw new BadRequestException("Please update your client to edit this item."); } diff --git a/src/Api/Vault/Models/CipherFido2KeyModel.cs b/src/Api/Vault/Models/CipherFido2CredentialModel.cs similarity index 80% rename from src/Api/Vault/Models/CipherFido2KeyModel.cs rename to src/Api/Vault/Models/CipherFido2CredentialModel.cs index 4d45bb24d585..32f6104a9aa4 100644 --- a/src/Api/Vault/Models/CipherFido2KeyModel.cs +++ b/src/Api/Vault/Models/CipherFido2CredentialModel.cs @@ -4,11 +4,11 @@ namespace Bit.Api.Vault.Models; -public class CipherFido2KeyModel +public class CipherFido2CredentialModel { - public CipherFido2KeyModel() { } + public CipherFido2CredentialModel() { } - public CipherFido2KeyModel(CipherLoginFido2KeyData data) + public CipherFido2CredentialModel(CipherLoginFido2CredentialData data) { CredentialId = data.CredentialId; KeyType = data.KeyType; @@ -60,9 +60,9 @@ public CipherFido2KeyModel(CipherLoginFido2KeyData data) [Required] public DateTime CreationDate { get; set; } - public CipherLoginFido2KeyData ToCipherLoginFido2KeyData() + public CipherLoginFido2CredentialData ToCipherLoginFido2CredentialData() { - return new CipherLoginFido2KeyData + return new CipherLoginFido2CredentialData { CredentialId = CredentialId, KeyType = KeyType, @@ -80,10 +80,10 @@ public CipherLoginFido2KeyData ToCipherLoginFido2KeyData() } } -static class CipherFido2KeyModelExtensions +static class CipherFido2CredentialModelExtensions { - public static CipherLoginFido2KeyData[] ToCipherLoginFido2KeyData(this CipherFido2KeyModel[] models) + public static CipherLoginFido2CredentialData[] ToCipherLoginFido2CredentialData(this CipherFido2CredentialModel[] models) { - return models.Select(m => m.ToCipherLoginFido2KeyData()).ToArray(); + return models.Select(m => m.ToCipherLoginFido2CredentialData()).ToArray(); } } diff --git a/src/Api/Vault/Models/CipherLoginModel.cs b/src/Api/Vault/Models/CipherLoginModel.cs index 38266e49d920..d1ea16751347 100644 --- a/src/Api/Vault/Models/CipherLoginModel.cs +++ b/src/Api/Vault/Models/CipherLoginModel.cs @@ -16,9 +16,9 @@ public CipherLoginModel(CipherLoginData data) Uri = data.Uri; } - if (data.Fido2Keys != null) + if (data.Fido2Credentials != null) { - Fido2Keys = data.Fido2Keys.Select(key => new CipherFido2KeyModel(key)).ToArray(); + Fido2Credentials = data.Fido2Credentials.Select(key => new CipherFido2CredentialModel(key)).ToArray(); } Username = data.Username; @@ -60,7 +60,7 @@ public string Uri [EncryptedStringLength(1000)] public string Totp { get; set; } public bool? AutofillOnPageLoad { get; set; } - public CipherFido2KeyModel[] Fido2Keys { get; set; } + public CipherFido2CredentialModel[] Fido2Credentials { get; set; } public class CipherLoginUriModel { diff --git a/src/Api/Vault/Models/Request/CipherRequestModel.cs b/src/Api/Vault/Models/Request/CipherRequestModel.cs index caaee31bb1e5..b62f2ff96e35 100644 --- a/src/Api/Vault/Models/Request/CipherRequestModel.cs +++ b/src/Api/Vault/Models/Request/CipherRequestModel.cs @@ -166,7 +166,7 @@ private CipherLoginData ToCipherLoginData() PasswordRevisionDate = Login.PasswordRevisionDate, Totp = Login.Totp, AutofillOnPageLoad = Login.AutofillOnPageLoad, - Fido2Keys = Login.Fido2Keys == null ? null : Login.Fido2Keys.ToCipherLoginFido2KeyData(), + Fido2Credentials = Login.Fido2Credentials == null ? null : Login.Fido2Credentials.ToCipherLoginFido2CredentialData(), }; } diff --git a/src/Api/Vault/Models/Response/CipherResponseModel.cs b/src/Api/Vault/Models/Response/CipherResponseModel.cs index a5d21bc0b3e4..ab79cc36008c 100644 --- a/src/Api/Vault/Models/Response/CipherResponseModel.cs +++ b/src/Api/Vault/Models/Response/CipherResponseModel.cs @@ -76,7 +76,6 @@ public CipherMiniResponseModel(Cipher cipher, IGlobalSettings globalSettings, bo public CipherCardModel Card { get; set; } public CipherIdentityModel Identity { get; set; } public CipherSecureNoteModel SecureNote { get; set; } - public CipherFido2KeyModel Fido2Key { get; set; } public IEnumerable Fields { get; set; } public IEnumerable PasswordHistory { get; set; } public IEnumerable Attachments { get; set; } diff --git a/src/Core/Vault/Models/Data/CipherLoginData.cs b/src/Core/Vault/Models/Data/CipherLoginData.cs index 39380bc34800..e952b39cf231 100644 --- a/src/Core/Vault/Models/Data/CipherLoginData.cs +++ b/src/Core/Vault/Models/Data/CipherLoginData.cs @@ -19,7 +19,7 @@ public string Uri public DateTime? PasswordRevisionDate { get; set; } public string Totp { get; set; } public bool? AutofillOnPageLoad { get; set; } - public CipherLoginFido2KeyData[] Fido2Keys { get; set; } + public CipherLoginFido2CredentialData[] Fido2Credentials { get; set; } public class CipherLoginUriData { diff --git a/src/Core/Vault/Models/Data/CipherLoginFido2KeyData.cs b/src/Core/Vault/Models/Data/CipherLoginFido2CredentialData.cs similarity index 85% rename from src/Core/Vault/Models/Data/CipherLoginFido2KeyData.cs rename to src/Core/Vault/Models/Data/CipherLoginFido2CredentialData.cs index 33fbd163b0d3..c0801d2a6ccc 100644 --- a/src/Core/Vault/Models/Data/CipherLoginFido2KeyData.cs +++ b/src/Core/Vault/Models/Data/CipherLoginFido2CredentialData.cs @@ -1,8 +1,8 @@ namespace Bit.Core.Vault.Models.Data; -public class CipherLoginFido2KeyData +public class CipherLoginFido2CredentialData { - public CipherLoginFido2KeyData() { } + public CipherLoginFido2CredentialData() { } public string CredentialId { get; set; } public string KeyType { get; set; }