Browse Source

[PM-3807] feat: remove standalone Fido2Key

PM-3807-store-all-passkeys-as-login-cipher-type
Andreas Coroiu 2 years ago
parent
commit
29aa75bb11
No known key found for this signature in database
GPG Key ID: E70B5FFC81DFEC1A
  1. 20
      src/Api/Vault/Controllers/SyncController.cs
  2. 15
      src/Api/Vault/Models/CipherFido2KeyModel.cs
  3. 25
      src/Api/Vault/Models/Request/CipherRequestModel.cs
  4. 6
      src/Api/Vault/Models/Response/CipherResponseModel.cs
  5. 1
      src/Core/Vault/Enums/CipherType.cs
  6. 18
      src/Core/Vault/Models/Data/CipherFido2KeyData.cs

20
src/Api/Vault/Controllers/SyncController.cs

@ -1,6 +1,4 @@ @@ -1,6 +1,4 @@
using Bit.Api.Vault.Models.Response;
using Bit.Core;
using Bit.Core.Context;
using Bit.Core.Entities;
using Bit.Core.Enums;
using Bit.Core.Enums.Provider;
@ -10,7 +8,6 @@ using Bit.Core.Repositories; @@ -10,7 +8,6 @@ using Bit.Core.Repositories;
using Bit.Core.Services;
using Bit.Core.Settings;
using Bit.Core.Tools.Repositories;
using Bit.Core.Vault.Models.Data;
using Bit.Core.Vault.Repositories;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
@ -31,8 +28,6 @@ public class SyncController : Controller @@ -31,8 +28,6 @@ public class SyncController : Controller
private readonly IPolicyRepository _policyRepository;
private readonly ISendRepository _sendRepository;
private readonly GlobalSettings _globalSettings;
private readonly ICurrentContext _currentContext;
private readonly Version _fido2KeyCipherMinimumVersion = new Version(Constants.Fido2KeyCipherMinimumVersion);
public SyncController(
IUserService userService,
@ -44,8 +39,7 @@ public class SyncController : Controller @@ -44,8 +39,7 @@ public class SyncController : Controller
IProviderUserRepository providerUserRepository,
IPolicyRepository policyRepository,
ISendRepository sendRepository,
GlobalSettings globalSettings,
ICurrentContext currentContext)
GlobalSettings globalSettings)
{
_userService = userService;
_folderRepository = folderRepository;
@ -57,7 +51,6 @@ public class SyncController : Controller @@ -57,7 +51,6 @@ public class SyncController : Controller
_policyRepository = policyRepository;
_sendRepository = sendRepository;
_globalSettings = globalSettings;
_currentContext = currentContext;
}
[HttpGet("")]
@ -79,7 +72,7 @@ public class SyncController : Controller @@ -79,7 +72,7 @@ public class SyncController : Controller
var hasEnabledOrgs = organizationUserDetails.Any(o => o.Enabled);
var folders = await _folderRepository.GetManyByUserIdAsync(user.Id);
var allCiphers = await _cipherRepository.GetManyByUserIdAsync(user.Id, hasEnabledOrgs);
var ciphers = FilterFidoKeys(allCiphers);
var ciphers = allCiphers;
var sends = await _sendRepository.GetManyByUserIdAsync(user.Id);
IEnumerable<CollectionDetails> collections = null;
@ -100,13 +93,4 @@ public class SyncController : Controller @@ -100,13 +93,4 @@ public class SyncController : Controller
collectionCiphersGroupDict, excludeDomains, policies, sends);
return response;
}
private ICollection<CipherDetails> FilterFidoKeys(ICollection<CipherDetails> ciphers)
{
if (_currentContext.ClientVersion >= _fido2KeyCipherMinimumVersion)
{
return ciphers;
}
return ciphers.Where(c => c.Type != Core.Vault.Enums.CipherType.Fido2Key).ToList();
}
}

15
src/Api/Vault/Models/CipherFido2KeyModel.cs

@ -7,21 +7,6 @@ public class CipherFido2KeyModel @@ -7,21 +7,6 @@ public class CipherFido2KeyModel
{
public CipherFido2KeyModel() { }
public CipherFido2KeyModel(CipherFido2KeyData data)
{
CredentialId = data.CredentialId;
KeyType = data.KeyType;
KeyAlgorithm = data.KeyAlgorithm;
KeyCurve = data.KeyCurve;
KeyValue = data.KeyValue;
RpId = data.RpId;
RpName = data.RpName;
UserHandle = data.UserHandle;
UserDisplayName = data.UserDisplayName;
Counter = data.Counter;
Discoverable = data.Discoverable;
}
public CipherFido2KeyModel(CipherLoginFido2KeyData data)
{
CredentialId = data.CredentialId;

25
src/Api/Vault/Models/Request/CipherRequestModel.cs

@ -82,9 +82,6 @@ public class CipherRequestModel @@ -82,9 +82,6 @@ public class CipherRequestModel
case CipherType.SecureNote:
existingCipher.Data = JsonSerializer.Serialize(ToCipherSecureNoteData(), JsonHelpers.IgnoreWritingNull);
break;
case CipherType.Fido2Key:
existingCipher.Data = JsonSerializer.Serialize(ToCipherFido2KeyData(), JsonHelpers.IgnoreWritingNull);
break;
default:
throw new ArgumentException("Unsupported type: " + nameof(Type) + ".");
}
@ -232,28 +229,6 @@ public class CipherRequestModel @@ -232,28 +229,6 @@ public class CipherRequestModel
Type = SecureNote.Type,
};
}
private CipherFido2KeyData ToCipherFido2KeyData()
{
return new CipherFido2KeyData
{
Name = Name,
Notes = Notes,
Fields = Fields?.Select(f => f.ToCipherFieldData()),
PasswordHistory = PasswordHistory?.Select(ph => ph.ToCipherPasswordHistoryData()),
CredentialId = Fido2Key.CredentialId,
KeyAlgorithm = Fido2Key.KeyAlgorithm,
KeyType = Fido2Key.KeyType,
KeyCurve = Fido2Key.KeyCurve,
KeyValue = Fido2Key.KeyValue,
RpId = Fido2Key.RpId,
RpName = Fido2Key.RpName,
UserHandle = Fido2Key.UserHandle,
UserDisplayName = Fido2Key.UserDisplayName,
Counter = Fido2Key.Counter
};
}
}
public class CipherWithIdRequestModel : CipherRequestModel

6
src/Api/Vault/Models/Response/CipherResponseModel.cs

@ -48,12 +48,6 @@ public class CipherMiniResponseModel : ResponseModel @@ -48,12 +48,6 @@ public class CipherMiniResponseModel : ResponseModel
cipherData = identityData;
Identity = new CipherIdentityModel(identityData);
break;
case CipherType.Fido2Key:
var fido2KeyData = JsonSerializer.Deserialize<CipherFido2KeyData>(cipher.Data);
Data = fido2KeyData;
cipherData = fido2KeyData;
Fido2Key = new CipherFido2KeyModel(fido2KeyData);
break;
default:
throw new ArgumentException("Unsupported " + nameof(Type) + ".");
}

1
src/Core/Vault/Enums/CipherType.cs

@ -8,5 +8,4 @@ public enum CipherType : byte @@ -8,5 +8,4 @@ public enum CipherType : byte
SecureNote = 2,
Card = 3,
Identity = 4,
Fido2Key = 5,
}

18
src/Core/Vault/Models/Data/CipherFido2KeyData.cs

@ -1,18 +0,0 @@ @@ -1,18 +0,0 @@
namespace Bit.Core.Vault.Models.Data;
public class CipherFido2KeyData : CipherData
{
public CipherFido2KeyData() { }
public string CredentialId { get; set; }
public string KeyType { get; set; }
public string KeyAlgorithm { get; set; }
public string KeyCurve { get; set; }
public string KeyValue { get; set; }
public string RpId { get; set; }
public string RpName { get; set; }
public string UserHandle { get; set; }
public string UserDisplayName { get; set; }
public string Counter { get; set; }
public string Discoverable { get; set; }
}
Loading…
Cancel
Save