1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-03 17:13:50 +00:00

[PM-3811] Passkeys unification (#2774)

* PM-3811 Unified passkeys view and moved both inside Login as an array of FIdo2Key

* PM-3811 Passkeys unification => updated cipher details view an helpers

* PM-3811 Updated passkeys creation date time format
This commit is contained in:
Federico Maccaroni
2023-09-22 11:55:35 -03:00
committed by GitHub
parent 6ef6cf5d84
commit a4a0d31fc6
28 changed files with 7367 additions and 5018 deletions

View File

@@ -549,28 +549,15 @@ namespace Bit.Core.Services
private async Task<bool> ValidateCanBeSharedWithOrgAsync(CipherView cipher, string organizationId)
{
if (cipher.Login?.Fido2Key is null && cipher.Fido2Key is null)
if (!cipher.HasFido2Key)
{
return true;
}
var decCiphers = await GetAllDecryptedAsync();
var orgCiphers = decCiphers.Where(c => c.OrganizationId == organizationId);
if (cipher.Login?.Fido2Key != null)
{
return !orgCiphers.Any(c => !cipher.Login.Fido2Key.IsUniqueAgainst(c.Login?.Fido2Key)
||
!cipher.Login.Fido2Key.IsUniqueAgainst(c.Fido2Key));
}
if (cipher.Fido2Key != null)
{
return !orgCiphers.Any(c => !cipher.Fido2Key.IsUniqueAgainst(c.Login?.Fido2Key)
||
!cipher.Fido2Key.IsUniqueAgainst(c.Fido2Key));
}
return true;
return !decCiphers
.Where(c => c.OrganizationId == organizationId)
.Any(c => !cipher.Login.MainFido2Key.IsUniqueAgainst(c.Login?.MainFido2Key));
}
public async Task<Cipher> SaveAttachmentRawWithServerAsync(Cipher cipher, string filename, byte[] data)
@@ -1132,10 +1119,15 @@ namespace Bit.Core.Services
cipher.Login.Uris.Add(loginUri);
}
}
if (model.Login.Fido2Key != null)
if (model.Login.HasFido2Keys)
{
cipher.Login.Fido2Key = new Fido2Key();
await EncryptObjPropertyAsync(model.Login.Fido2Key, cipher.Login.Fido2Key, Fido2Key.EncryptableProperties, key);
cipher.Login.Fido2Keys = new List<Fido2Key>();
foreach (var fido2Key in model.Login.Fido2Keys)
{
var fido2KeyDomain = new Fido2Key();
await EncryptObjPropertyAsync(fido2Key, fido2KeyDomain, Fido2Key.EncryptableProperties, key);
cipher.Login.Fido2Keys.Add(fido2KeyDomain);
}
}
break;
case CipherType.SecureNote:
@@ -1180,10 +1172,6 @@ namespace Bit.Core.Services
"LicenseNumber"
}, key);
break;
case CipherType.Fido2Key:
cipher.Fido2Key = new Fido2Key();
await EncryptObjPropertyAsync(model.Fido2Key, cipher.Fido2Key, Fido2Key.EncryptableProperties, key);
break;
default:
throw new Exception("Unknown cipher type.");
}