1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-03 00:53:27 +00:00

[PM-1575] Display Passkeys (#2523)

* PM-1575 Added new models for Fido2Key

* PM-1575 Added discoverable passkeys and WIP non-discoverable ones

* PM-1575 Fix format

* PM-1575 Added non-discoverable passkeys to login UI

* PM-1575 Added copy application icon to Fido2Key UI

* PM-1575 Updated bwi font with the updated passkey icon

* PM-1575 For now just display Available for two-step login on non-discoverable passkey inside of a cipher login

* PM-1575 Fix non-discoverable passkey visibility

* PM-1575 remove Passkeys as a filter in the vault list

* PM-1575 Display error toast if there is a duplicate passkey when moving a cipher to an org

* Revert "PM-1575 Display error toast if there is a duplicate passkey when moving a cipher to an org"

This reverts commit 78e6353602.

* [PM-2378] Display error toast on duplicate Passkey when moving cipher to an organization (#2594)

* PM-2378 Display error toast if there is a duplicate passkey when moving a cipher to an org

* PM-3097 Fix issue when moving cipher with passkey to an org where the uniqueness should be taken into consideration on different passkeys types and also the Username (#2632)

* PM-3096 Fix non-discoverable passkey to be taken into account when encrypting a cipher which was causing the passkey to be removed when moving to an org (#2637)
This commit is contained in:
Federico Maccaroni
2023-07-26 17:59:49 -03:00
committed by GitHub
parent 174549e5bc
commit ea81acb3bf
42 changed files with 664 additions and 131 deletions

View File

@@ -176,6 +176,7 @@ namespace Bit.Core.Services
OrganizationId = model.OrganizationId,
Type = model.Type,
CollectionIds = model.CollectionIds,
CreationDate = model.CreationDate,
RevisionDate = model.RevisionDate,
Reprompt = model.Reprompt
};
@@ -531,8 +532,13 @@ namespace Bit.Core.Services
await UpsertAsync(data);
}
public async Task ShareWithServerAsync(CipherView cipher, string organizationId, HashSet<string> collectionIds)
public async Task<ICipherService.ShareWithServerError> ShareWithServerAsync(CipherView cipher, string organizationId, HashSet<string> collectionIds)
{
if (!await ValidateCanBeSharedWithOrgAsync(cipher, organizationId))
{
return ICipherService.ShareWithServerError.DuplicatedPasskeyInOrg;
}
var attachmentTasks = new List<Task>();
if (cipher.Attachments != null)
{
@@ -553,6 +559,34 @@ namespace Bit.Core.Services
var userId = await _stateService.GetActiveUserIdAsync();
var data = new CipherData(response, userId, collectionIds);
await UpsertAsync(data);
return ICipherService.ShareWithServerError.None;
}
private async Task<bool> ValidateCanBeSharedWithOrgAsync(CipherView cipher, string organizationId)
{
if (cipher.Login?.Fido2Key is null && cipher.Fido2Key is null)
{
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;
}
public async Task<Cipher> SaveAttachmentRawWithServerAsync(Cipher cipher, string filename, byte[] data)
@@ -1104,6 +1138,11 @@ namespace Bit.Core.Services
cipher.Login.Uris.Add(loginUri);
}
}
if (model.Login.Fido2Key != null)
{
cipher.Login.Fido2Key = new Fido2Key();
await EncryptObjPropertyAsync(model.Login.Fido2Key, cipher.Login.Fido2Key, Fido2Key.EncryptableProperties, key);
}
break;
case CipherType.SecureNote:
cipher.SecureNote = new SecureNote
@@ -1147,6 +1186,10 @@ 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.");
}
@@ -1229,8 +1272,8 @@ namespace Bit.Core.Services
public int Compare(CipherView a, CipherView b)
{
var aName = a?.Name;
var bName = b?.Name;
var aName = a?.ComparableName;
var bName = b?.ComparableName;
if (aName == null && bName != null)
{
return -1;
@@ -1243,19 +1286,6 @@ namespace Bit.Core.Services
{
return 0;
}
var result = _i18nService.StringComparer.Compare(aName, bName);
if (result != 0 || a.Type != CipherType.Login || b.Type != CipherType.Login)
{
return result;
}
if (a.Login.Username != null)
{
aName += a.Login.Username;
}
if (b.Login.Username != null)
{
bName += b.Login.Username;
}
return _i18nService.StringComparer.Compare(aName, bName);
}
}