mirror of
https://github.com/bitwarden/mobile
synced 2025-12-24 04:04:34 +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:
committed by
GitHub
parent
6ef6cf5d84
commit
a4a0d31fc6
@@ -1,5 +1,4 @@
|
||||
using Bit.Core.Models.Domain;
|
||||
using Bit.Core.Models.Export;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
@@ -11,7 +10,8 @@ namespace Bit.Core.Models.Api
|
||||
|
||||
public Fido2KeyApi(Fido2Key fido2Key)
|
||||
{
|
||||
NonDiscoverableId = fido2Key.NonDiscoverableId?.EncryptedString;
|
||||
CredentialId = fido2Key.CredentialId?.EncryptedString;
|
||||
Discoverable = fido2Key.Discoverable?.EncryptedString;
|
||||
KeyType = fido2Key.KeyType?.EncryptedString;
|
||||
KeyAlgorithm = fido2Key.KeyAlgorithm?.EncryptedString;
|
||||
KeyCurve = fido2Key.KeyCurve?.EncryptedString;
|
||||
@@ -23,7 +23,8 @@ namespace Bit.Core.Models.Api
|
||||
Counter = fido2Key.Counter?.EncryptedString;
|
||||
}
|
||||
|
||||
public string NonDiscoverableId { get; set; }
|
||||
public string CredentialId { get; set; }
|
||||
public string Discoverable { get; set; }
|
||||
public string KeyType { get; set; } = Constants.DefaultFido2KeyType;
|
||||
public string KeyAlgorithm { get; set; } = Constants.DefaultFido2KeyAlgorithm;
|
||||
public string KeyCurve { get; set; } = Constants.DefaultFido2KeyCurve;
|
||||
|
||||
@@ -10,6 +10,6 @@ namespace Bit.Core.Models.Api
|
||||
public string Password { get; set; }
|
||||
public DateTime? PasswordRevisionDate { get; set; }
|
||||
public string Totp { get; set; }
|
||||
public Fido2KeyApi Fido2Key { get; set; }
|
||||
public List<Fido2KeyApi> Fido2Keys { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,9 +45,6 @@ namespace Bit.Core.Models.Data
|
||||
case Enums.CipherType.Identity:
|
||||
Identity = new IdentityData(response.Identity);
|
||||
break;
|
||||
case Enums.CipherType.Fido2Key:
|
||||
Fido2Key = new Fido2KeyData(response.Fido2Key);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -86,7 +83,6 @@ namespace Bit.Core.Models.Data
|
||||
public SecureNoteData SecureNote { get; set; }
|
||||
public CardData Card { get; set; }
|
||||
public IdentityData Identity { get; set; }
|
||||
public Fido2KeyData Fido2Key { get; set; }
|
||||
public List<FieldData> Fields { get; set; }
|
||||
public List<AttachmentData> Attachments { get; set; }
|
||||
public List<PasswordHistoryData> PasswordHistory { get; set; }
|
||||
|
||||
@@ -8,7 +8,8 @@ namespace Bit.Core.Models.Data
|
||||
|
||||
public Fido2KeyData(Fido2KeyApi apiData)
|
||||
{
|
||||
NonDiscoverableId = apiData.NonDiscoverableId;
|
||||
CredentialId = apiData.CredentialId;
|
||||
Discoverable = apiData.Discoverable;
|
||||
KeyType = apiData.KeyType;
|
||||
KeyAlgorithm = apiData.KeyAlgorithm;
|
||||
KeyCurve = apiData.KeyCurve;
|
||||
@@ -20,7 +21,8 @@ namespace Bit.Core.Models.Data
|
||||
Counter = apiData.Counter;
|
||||
}
|
||||
|
||||
public string NonDiscoverableId { get; set; }
|
||||
public string CredentialId { get; set; }
|
||||
public string Discoverable { get; set; }
|
||||
public string KeyType { get; set; } = Constants.DefaultFido2KeyType;
|
||||
public string KeyAlgorithm { get; set; } = Constants.DefaultFido2KeyAlgorithm;
|
||||
public string KeyCurve { get; set; } = Constants.DefaultFido2KeyCurve;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Bit.Core.Models.Data
|
||||
PasswordRevisionDate = data.PasswordRevisionDate;
|
||||
Totp = data.Totp;
|
||||
Uris = data.Uris?.Select(u => new LoginUriData(u)).ToList();
|
||||
Fido2Key = data.Fido2Key != null ? new Fido2KeyData(data.Fido2Key) : null;
|
||||
Fido2Keys = data.Fido2Keys?.Select(f => new Fido2KeyData(f)).ToList();
|
||||
}
|
||||
|
||||
public List<LoginUriData> Uris { get; set; }
|
||||
@@ -24,6 +24,6 @@ namespace Bit.Core.Models.Data
|
||||
public string Password { get; set; }
|
||||
public DateTime? PasswordRevisionDate { get; set; }
|
||||
public string Totp { get; set; }
|
||||
public Fido2KeyData Fido2Key { get; set; }
|
||||
public List<Fido2KeyData> Fido2Keys { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,9 +48,6 @@ namespace Bit.Core.Models.Domain
|
||||
case Enums.CipherType.Identity:
|
||||
Identity = new Identity(obj.Identity, alreadyEncrypted);
|
||||
break;
|
||||
case CipherType.Fido2Key:
|
||||
Fido2Key = new Fido2Key(obj.Fido2Key, alreadyEncrypted);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -66,7 +63,7 @@ namespace Bit.Core.Models.Domain
|
||||
public string FolderId { get; set; }
|
||||
public EncString Name { get; set; }
|
||||
public EncString Notes { get; set; }
|
||||
public Enums.CipherType Type { get; set; }
|
||||
public CipherType Type { get; set; }
|
||||
public bool Favorite { get; set; }
|
||||
public bool OrganizationUseTotp { get; set; }
|
||||
public bool Edit { get; set; }
|
||||
@@ -79,7 +76,6 @@ namespace Bit.Core.Models.Domain
|
||||
public Identity Identity { get; set; }
|
||||
public Card Card { get; set; }
|
||||
public SecureNote SecureNote { get; set; }
|
||||
public Fido2Key Fido2Key { get; set; }
|
||||
public List<Attachment> Attachments { get; set; }
|
||||
public List<Field> Fields { get; set; }
|
||||
public List<PasswordHistory> PasswordHistory { get; set; }
|
||||
@@ -109,9 +105,6 @@ namespace Bit.Core.Models.Domain
|
||||
case Enums.CipherType.Identity:
|
||||
model.Identity = await Identity.DecryptAsync(OrganizationId);
|
||||
break;
|
||||
case Enums.CipherType.Fido2Key:
|
||||
model.Fido2Key = await Fido2Key.DecryptAsync(OrganizationId);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -201,9 +194,6 @@ namespace Bit.Core.Models.Domain
|
||||
case Enums.CipherType.Identity:
|
||||
c.Identity = Identity.ToIdentityData();
|
||||
break;
|
||||
case Enums.CipherType.Fido2Key:
|
||||
c.Fido2Key = Fido2Key.ToFido2KeyData();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ namespace Bit.Core.Models.Domain
|
||||
{
|
||||
public static HashSet<string> EncryptableProperties => new HashSet<string>
|
||||
{
|
||||
nameof(NonDiscoverableId),
|
||||
nameof(CredentialId),
|
||||
nameof(Discoverable),
|
||||
nameof(KeyType),
|
||||
nameof(KeyAlgorithm),
|
||||
nameof(KeyCurve),
|
||||
@@ -28,7 +29,8 @@ namespace Bit.Core.Models.Domain
|
||||
BuildDomainModel(this, data, EncryptableProperties, alreadyEncrypted);
|
||||
}
|
||||
|
||||
public EncString NonDiscoverableId { get; set; }
|
||||
public EncString CredentialId { get; set; }
|
||||
public EncString Discoverable { get; set; }
|
||||
public EncString KeyType { get; set; }
|
||||
public EncString KeyAlgorithm { get; set; }
|
||||
public EncString KeyCurve { get; set; }
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Bit.Core.Models.Domain
|
||||
{
|
||||
PasswordRevisionDate = obj.PasswordRevisionDate;
|
||||
Uris = obj.Uris?.Select(u => new LoginUri(u, alreadyEncrypted)).ToList();
|
||||
Fido2Key = obj.Fido2Key != null ? new Fido2Key(obj.Fido2Key, alreadyEncrypted) : null;
|
||||
Fido2Keys = obj.Fido2Keys?.Select(f => new Fido2Key(f, alreadyEncrypted)).ToList();
|
||||
BuildDomainModel(this, obj, new HashSet<string>
|
||||
{
|
||||
"Username",
|
||||
@@ -29,7 +29,7 @@ namespace Bit.Core.Models.Domain
|
||||
public EncString Password { get; set; }
|
||||
public DateTime? PasswordRevisionDate { get; set; }
|
||||
public EncString Totp { get; set; }
|
||||
public Fido2Key Fido2Key { get; set; }
|
||||
public List<Fido2Key> Fido2Keys { get; set; }
|
||||
|
||||
public async Task<LoginView> DecryptAsync(string orgId)
|
||||
{
|
||||
@@ -47,9 +47,13 @@ namespace Bit.Core.Models.Domain
|
||||
view.Uris.Add(await uri.DecryptAsync(orgId));
|
||||
}
|
||||
}
|
||||
if (Fido2Key != null)
|
||||
if (Fido2Keys != null)
|
||||
{
|
||||
view.Fido2Key = await Fido2Key.DecryptAsync(orgId);
|
||||
view.Fido2Keys = new List<Fido2KeyView>();
|
||||
foreach (var fido2Key in Fido2Keys)
|
||||
{
|
||||
view.Fido2Keys.Add(await fido2Key.DecryptAsync(orgId));
|
||||
}
|
||||
}
|
||||
return view;
|
||||
}
|
||||
@@ -68,9 +72,9 @@ namespace Bit.Core.Models.Domain
|
||||
{
|
||||
l.Uris = Uris.Select(u => u.ToLoginUriData()).ToList();
|
||||
}
|
||||
if (Fido2Key != null)
|
||||
if (Fido2Keys != null)
|
||||
{
|
||||
l.Fido2Key = Fido2Key.ToFido2KeyData();
|
||||
l.Fido2Keys = Fido2Keys.Select(f => f.ToFido2KeyData()).ToList();
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Bit.Core.Models.Request
|
||||
Password = cipher.Login.Password?.EncryptedString,
|
||||
PasswordRevisionDate = cipher.Login.PasswordRevisionDate,
|
||||
Totp = cipher.Login.Totp?.EncryptedString,
|
||||
Fido2Key = cipher.Login.Fido2Key != null ? new Fido2KeyApi(cipher.Login.Fido2Key) : null
|
||||
Fido2Keys = cipher.Login.Fido2Keys?.Select(f => new Fido2KeyApi(f)).ToList()
|
||||
};
|
||||
break;
|
||||
case CipherType.Card:
|
||||
@@ -74,9 +74,6 @@ namespace Bit.Core.Models.Request
|
||||
Type = cipher.SecureNote.Type
|
||||
};
|
||||
break;
|
||||
case CipherType.Fido2Key:
|
||||
Fido2Key = new Fido2KeyApi(cipher.Fido2Key);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -122,7 +119,6 @@ namespace Bit.Core.Models.Request
|
||||
public SecureNoteApi SecureNote { get; set; }
|
||||
public CardApi Card { get; set; }
|
||||
public IdentityApi Identity { get; set; }
|
||||
public Fido2KeyApi Fido2Key { get; set; }
|
||||
public List<FieldApi> Fields { get; set; }
|
||||
public List<PasswordHistoryRequest> PasswordHistory { get; set; }
|
||||
public Dictionary<string, string> Attachments { get; set; }
|
||||
|
||||
@@ -18,7 +18,6 @@ namespace Bit.Core.Models.Response
|
||||
public CardApi Card { get; set; }
|
||||
public IdentityApi Identity { get; set; }
|
||||
public SecureNoteApi SecureNote { get; set; }
|
||||
public Fido2KeyApi Fido2Key { get; set; }
|
||||
public bool Favorite { get; set; }
|
||||
public bool Edit { get; set; }
|
||||
public bool ViewPassword { get; set; } = true; // Fallback for old server versions
|
||||
|
||||
@@ -43,7 +43,6 @@ namespace Bit.Core.Models.View
|
||||
public IdentityView Identity { get; set; }
|
||||
public CardView Card { get; set; }
|
||||
public SecureNoteView SecureNote { get; set; }
|
||||
public Fido2KeyView Fido2Key { get; set; }
|
||||
public List<AttachmentView> Attachments { get; set; }
|
||||
public List<FieldView> Fields { get; set; }
|
||||
public List<PasswordHistoryView> PasswordHistory { get; set; }
|
||||
@@ -67,8 +66,6 @@ namespace Bit.Core.Models.View
|
||||
return Card;
|
||||
case CipherType.Identity:
|
||||
return Identity;
|
||||
case CipherType.Fido2Key:
|
||||
return Fido2Key;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -115,12 +112,14 @@ namespace Bit.Core.Models.View
|
||||
return LinkedFieldOptions.Find(lfo => lfo.Value == id).Key;
|
||||
}
|
||||
|
||||
public string ComparableName => Name + Login?.Username + Fido2Key?.UserName;
|
||||
public string ComparableName => Name + Login?.Username;
|
||||
|
||||
public bool CanLaunch => Login?.CanLaunch == true || Fido2Key?.CanLaunch == true;
|
||||
public bool CanLaunch => Login?.CanLaunch == true;
|
||||
|
||||
public string LaunchUri => Login?.LaunchUri ?? Fido2Key?.LaunchUri;
|
||||
public string LaunchUri => Login?.LaunchUri;
|
||||
|
||||
public bool IsClonable => OrganizationId is null && Type != CipherType.Fido2Key;
|
||||
public bool IsClonable => OrganizationId is null;
|
||||
|
||||
public bool HasFido2Key => Type == CipherType.Login && Login?.HasFido2Keys == true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@ namespace Bit.Core.Models.View
|
||||
{
|
||||
public class Fido2KeyView : ItemView, ILaunchableView
|
||||
{
|
||||
public string NonDiscoverableId { get; set; }
|
||||
public string CredentialId { get; set; }
|
||||
public string Discoverable { get; set; }
|
||||
public string KeyType { get; set; } = Constants.DefaultFido2KeyType;
|
||||
public string KeyAlgorithm { get; set; } = Constants.DefaultFido2KeyAlgorithm;
|
||||
public string KeyCurve { get; set; } = Constants.DefaultFido2KeyCurve;
|
||||
@@ -18,6 +19,7 @@ namespace Bit.Core.Models.View
|
||||
|
||||
public override string SubTitle => UserName;
|
||||
public override List<KeyValuePair<string, LinkedIdType>> LinkedFieldOptions => new List<KeyValuePair<string, LinkedIdType>>();
|
||||
public bool IsDiscoverable => !string.IsNullOrWhiteSpace(Discoverable);
|
||||
public bool CanLaunch => !string.IsNullOrEmpty(RpId);
|
||||
public string LaunchUri => $"https://{RpId}";
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Bit.Core.Models.View
|
||||
public DateTime? PasswordRevisionDate { get; set; }
|
||||
public string Totp { get; set; }
|
||||
public List<LoginUriView> Uris { get; set; }
|
||||
public Fido2KeyView Fido2Key { get; set; }
|
||||
public List<Fido2KeyView> Fido2Keys { get; set; }
|
||||
|
||||
public string Uri => HasUris ? Uris[0].Uri : null;
|
||||
public string MaskedPassword => Password != null ? "••••••••" : null;
|
||||
@@ -28,6 +28,8 @@ namespace Bit.Core.Models.View
|
||||
public bool CanLaunch => HasUris && Uris.Any(u => u.CanLaunch);
|
||||
public string LaunchUri => HasUris ? Uris.FirstOrDefault(u => u.CanLaunch)?.LaunchUri : null;
|
||||
public bool HasUris => (Uris?.Count ?? 0) > 0;
|
||||
public bool HasFido2Keys => Fido2Keys?.Any() == true;
|
||||
public Fido2KeyView MainFido2Key => HasFido2Keys ? Fido2Keys[0] : null;
|
||||
|
||||
public override List<KeyValuePair<string, LinkedIdType>> LinkedFieldOptions
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user