mirror of
https://github.com/bitwarden/mobile
synced 2025-12-23 11:43:49 +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:
committed by
GitHub
parent
174549e5bc
commit
ea81acb3bf
37
src/Core/Models/Api/Fido2KeyApi.cs
Normal file
37
src/Core/Models/Api/Fido2KeyApi.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using Bit.Core.Models.Domain;
|
||||
using Bit.Core.Models.Export;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
public class Fido2KeyApi
|
||||
{
|
||||
public Fido2KeyApi()
|
||||
{
|
||||
}
|
||||
|
||||
public Fido2KeyApi(Fido2Key fido2Key)
|
||||
{
|
||||
NonDiscoverableId = fido2Key.NonDiscoverableId?.EncryptedString;
|
||||
KeyType = fido2Key.KeyType?.EncryptedString;
|
||||
KeyAlgorithm = fido2Key.KeyAlgorithm?.EncryptedString;
|
||||
KeyCurve = fido2Key.KeyCurve?.EncryptedString;
|
||||
KeyValue = fido2Key.KeyValue?.EncryptedString;
|
||||
RpId = fido2Key.RpId?.EncryptedString;
|
||||
RpName = fido2Key.RpName?.EncryptedString;
|
||||
UserHandle = fido2Key.UserHandle?.EncryptedString;
|
||||
UserName = fido2Key.UserName?.EncryptedString;
|
||||
Counter = fido2Key.Counter?.EncryptedString;
|
||||
}
|
||||
|
||||
public string NonDiscoverableId { get; set; }
|
||||
public string KeyType { get; set; } = Constants.DefaultFido2KeyType;
|
||||
public string KeyAlgorithm { get; set; } = Constants.DefaultFido2KeyAlgorithm;
|
||||
public string KeyCurve { get; set; } = Constants.DefaultFido2KeyCurve;
|
||||
public string KeyValue { get; set; }
|
||||
public string RpId { get; set; }
|
||||
public string RpName { get; set; }
|
||||
public string UserHandle { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string Counter { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -10,5 +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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ namespace Bit.Core.Models.Data
|
||||
OrganizationUseTotp = response.OrganizationUseTotp;
|
||||
Favorite = response.Favorite;
|
||||
RevisionDate = response.RevisionDate;
|
||||
CreationDate = response.CreationDate;
|
||||
DeletedDate = response.DeletedDate;
|
||||
Type = response.Type;
|
||||
Name = response.Name;
|
||||
Notes = response.Notes;
|
||||
@@ -43,6 +45,9 @@ 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;
|
||||
}
|
||||
@@ -61,7 +66,6 @@ namespace Bit.Core.Models.Data
|
||||
Fields = response.Fields?.Select(f => new FieldData(f)).ToList();
|
||||
Attachments = response.Attachments?.Select(a => new AttachmentData(a)).ToList();
|
||||
PasswordHistory = response.PasswordHistory?.Select(ph => new PasswordHistoryData(ph)).ToList();
|
||||
DeletedDate = response.DeletedDate;
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
@@ -73,6 +77,8 @@ namespace Bit.Core.Models.Data
|
||||
public bool OrganizationUseTotp { get; set; }
|
||||
public bool Favorite { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
public DateTime CreationDate { get; set; }
|
||||
public DateTime? DeletedDate { get; set; }
|
||||
public Enums.CipherType Type { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Notes { get; set; }
|
||||
@@ -80,11 +86,11 @@ 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; }
|
||||
public List<string> CollectionIds { get; set; }
|
||||
public DateTime? DeletedDate { get; set; }
|
||||
public Enums.CipherRepromptType Reprompt { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
34
src/Core/Models/Data/Fido2KeyData.cs
Normal file
34
src/Core/Models/Data/Fido2KeyData.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Bit.Core.Models.Api;
|
||||
|
||||
namespace Bit.Core.Models.Data
|
||||
{
|
||||
public class Fido2KeyData : Data
|
||||
{
|
||||
public Fido2KeyData() { }
|
||||
|
||||
public Fido2KeyData(Fido2KeyApi apiData)
|
||||
{
|
||||
NonDiscoverableId = apiData.NonDiscoverableId;
|
||||
KeyType = apiData.KeyType;
|
||||
KeyAlgorithm = apiData.KeyAlgorithm;
|
||||
KeyCurve = apiData.KeyCurve;
|
||||
KeyValue = apiData.KeyValue;
|
||||
RpId = apiData.RpId;
|
||||
RpName = apiData.RpName;
|
||||
UserHandle = apiData.UserHandle;
|
||||
UserName = apiData.UserName;
|
||||
Counter = apiData.Counter;
|
||||
}
|
||||
|
||||
public string NonDiscoverableId { get; set; }
|
||||
public string KeyType { get; set; } = Constants.DefaultFido2KeyType;
|
||||
public string KeyAlgorithm { get; set; } = Constants.DefaultFido2KeyAlgorithm;
|
||||
public string KeyCurve { get; set; } = Constants.DefaultFido2KeyCurve;
|
||||
public string KeyValue { get; set; }
|
||||
public string RpId { get; set; }
|
||||
public string RpName { get; set; }
|
||||
public string UserHandle { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string Counter { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -16,6 +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;
|
||||
}
|
||||
|
||||
public List<LoginUriData> Uris { get; set; }
|
||||
@@ -23,5 +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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace Bit.Core.Models.Domain
|
||||
Edit = obj.Edit;
|
||||
ViewPassword = obj.ViewPassword;
|
||||
RevisionDate = obj.RevisionDate;
|
||||
CreationDate = obj.CreationDate;
|
||||
CollectionIds = obj.CollectionIds != null ? new HashSet<string>(obj.CollectionIds) : null;
|
||||
LocalData = localData;
|
||||
Reprompt = obj.Reprompt;
|
||||
@@ -47,6 +48,9 @@ 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;
|
||||
}
|
||||
@@ -68,16 +72,18 @@ namespace Bit.Core.Models.Domain
|
||||
public bool Edit { get; set; }
|
||||
public bool ViewPassword { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
public DateTime CreationDate { get; set; }
|
||||
public DateTime? DeletedDate { get; set; }
|
||||
public Dictionary<string, object> LocalData { get; set; }
|
||||
public Login Login { get; set; }
|
||||
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; }
|
||||
public HashSet<string> CollectionIds { get; set; }
|
||||
public DateTime? DeletedDate { get; set; }
|
||||
public CipherRepromptType Reprompt { get; set; }
|
||||
|
||||
public async Task<CipherView> DecryptAsync()
|
||||
@@ -103,6 +109,9 @@ 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;
|
||||
}
|
||||
@@ -167,6 +176,7 @@ namespace Bit.Core.Models.Domain
|
||||
OrganizationUseTotp = OrganizationUseTotp,
|
||||
Favorite = Favorite,
|
||||
RevisionDate = RevisionDate,
|
||||
CreationDate = CreationDate,
|
||||
Type = Type,
|
||||
CollectionIds = CollectionIds.ToList(),
|
||||
DeletedDate = DeletedDate,
|
||||
@@ -191,6 +201,9 @@ 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;
|
||||
}
|
||||
|
||||
54
src/Core/Models/Domain/Fido2Key.cs
Normal file
54
src/Core/Models/Domain/Fido2Key.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Bit.Core.Models.Data;
|
||||
using Bit.Core.Models.View;
|
||||
|
||||
namespace Bit.Core.Models.Domain
|
||||
{
|
||||
public class Fido2Key : Domain
|
||||
{
|
||||
public static HashSet<string> EncryptableProperties => new HashSet<string>
|
||||
{
|
||||
nameof(NonDiscoverableId),
|
||||
nameof(KeyType),
|
||||
nameof(KeyAlgorithm),
|
||||
nameof(KeyCurve),
|
||||
nameof(KeyValue),
|
||||
nameof(RpId),
|
||||
nameof(RpName),
|
||||
nameof(UserHandle),
|
||||
nameof(UserName),
|
||||
nameof(Counter)
|
||||
};
|
||||
|
||||
public Fido2Key() { }
|
||||
|
||||
public Fido2Key(Fido2KeyData data, bool alreadyEncrypted = false)
|
||||
{
|
||||
BuildDomainModel(this, data, EncryptableProperties, alreadyEncrypted);
|
||||
}
|
||||
|
||||
public EncString NonDiscoverableId { get; set; }
|
||||
public EncString KeyType { get; set; }
|
||||
public EncString KeyAlgorithm { get; set; }
|
||||
public EncString KeyCurve { get; set; }
|
||||
public EncString KeyValue { get; set; }
|
||||
public EncString RpId { get; set; }
|
||||
public EncString RpName { get; set; }
|
||||
public EncString UserHandle { get; set; }
|
||||
public EncString UserName { get; set; }
|
||||
public EncString Counter { get; set; }
|
||||
|
||||
public async Task<Fido2KeyView> DecryptAsync(string orgId)
|
||||
{
|
||||
return await DecryptObjAsync(new Fido2KeyView(), this, EncryptableProperties, orgId);
|
||||
}
|
||||
|
||||
public Fido2KeyData ToFido2KeyData()
|
||||
{
|
||||
var data = new Fido2KeyData();
|
||||
BuildDataModel(this, data, EncryptableProperties);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +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;
|
||||
BuildDomainModel(this, obj, new HashSet<string>
|
||||
{
|
||||
"Username",
|
||||
@@ -28,6 +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 async Task<LoginView> DecryptAsync(string orgId)
|
||||
{
|
||||
@@ -45,6 +47,10 @@ namespace Bit.Core.Models.Domain
|
||||
view.Uris.Add(await uri.DecryptAsync(orgId));
|
||||
}
|
||||
}
|
||||
if (Fido2Key != null)
|
||||
{
|
||||
view.Fido2Key = await Fido2Key.DecryptAsync(orgId);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -62,6 +68,10 @@ namespace Bit.Core.Models.Domain
|
||||
{
|
||||
l.Uris = Uris.Select(u => u.ToLoginUriData()).ToList();
|
||||
}
|
||||
if (Fido2Key != null)
|
||||
{
|
||||
l.Fido2Key = Fido2Key.ToFido2KeyData();
|
||||
}
|
||||
return l;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,8 @@ namespace Bit.Core.Models.Request
|
||||
Username = cipher.Login.Username?.EncryptedString,
|
||||
Password = cipher.Login.Password?.EncryptedString,
|
||||
PasswordRevisionDate = cipher.Login.PasswordRevisionDate,
|
||||
Totp = cipher.Login.Totp?.EncryptedString
|
||||
Totp = cipher.Login.Totp?.EncryptedString,
|
||||
Fido2Key = cipher.Login.Fido2Key != null ? new Fido2KeyApi(cipher.Login.Fido2Key) : null
|
||||
};
|
||||
break;
|
||||
case CipherType.Card:
|
||||
@@ -73,6 +74,9 @@ namespace Bit.Core.Models.Request
|
||||
Type = cipher.SecureNote.Type
|
||||
};
|
||||
break;
|
||||
case CipherType.Fido2Key:
|
||||
Fido2Key = new Fido2KeyApi(cipher.Fido2Key);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -118,6 +122,7 @@ 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,6 +18,7 @@ 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
|
||||
@@ -28,5 +29,6 @@ namespace Bit.Core.Models.Response
|
||||
public List<string> CollectionIds { get; set; }
|
||||
public DateTime? DeletedDate { get; set; }
|
||||
public CipherRepromptType Reprompt { get; set; }
|
||||
public DateTime CreationDate { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ using Bit.Core.Models.Domain;
|
||||
|
||||
namespace Bit.Core.Models.View
|
||||
{
|
||||
public class CipherView : View
|
||||
public class CipherView : View, ILaunchableView
|
||||
{
|
||||
public CipherView() { }
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace Bit.Core.Models.View
|
||||
LocalData = c.LocalData;
|
||||
CollectionIds = c.CollectionIds;
|
||||
RevisionDate = c.RevisionDate;
|
||||
CreationDate = c.CreationDate;
|
||||
DeletedDate = c.DeletedDate;
|
||||
Reprompt = c.Reprompt;
|
||||
}
|
||||
@@ -42,11 +43,13 @@ 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; }
|
||||
public HashSet<string> CollectionIds { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
public DateTime CreationDate { get; set; }
|
||||
public DateTime? DeletedDate { get; set; }
|
||||
public CipherRepromptType Reprompt { get; set; }
|
||||
|
||||
@@ -64,6 +67,8 @@ namespace Bit.Core.Models.View
|
||||
return Card;
|
||||
case CipherType.Identity:
|
||||
return Identity;
|
||||
case CipherType.Fido2Key:
|
||||
return Fido2Key;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -110,5 +115,10 @@ namespace Bit.Core.Models.View
|
||||
return LinkedFieldOptions.Find(lfo => lfo.Value == id).Key;
|
||||
}
|
||||
|
||||
public string ComparableName => Name + Login?.Username + Fido2Key?.UserName;
|
||||
|
||||
public bool CanLaunch => Login?.CanLaunch == true || Fido2Key?.CanLaunch == true;
|
||||
|
||||
public string LaunchUri => Login?.LaunchUri ?? Fido2Key?.LaunchUri;
|
||||
}
|
||||
}
|
||||
|
||||
26
src/Core/Models/View/Fido2KeyView.cs
Normal file
26
src/Core/Models/View/Fido2KeyView.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
using Bit.Core.Enums;
|
||||
|
||||
namespace Bit.Core.Models.View
|
||||
{
|
||||
public class Fido2KeyView : ItemView, ILaunchableView
|
||||
{
|
||||
public string NonDiscoverableId { get; set; }
|
||||
public string KeyType { get; set; } = Constants.DefaultFido2KeyType;
|
||||
public string KeyAlgorithm { get; set; } = Constants.DefaultFido2KeyAlgorithm;
|
||||
public string KeyCurve { get; set; } = Constants.DefaultFido2KeyCurve;
|
||||
public string KeyValue { get; set; }
|
||||
public string RpId { get; set; }
|
||||
public string RpName { get; set; }
|
||||
public string UserHandle { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string Counter { get; set; }
|
||||
|
||||
public override string SubTitle => UserName;
|
||||
public override List<KeyValuePair<string, LinkedIdType>> LinkedFieldOptions => new List<KeyValuePair<string, LinkedIdType>>();
|
||||
public bool CanLaunch => !string.IsNullOrEmpty(RpId);
|
||||
public string LaunchUri => $"https://{RpId}";
|
||||
|
||||
public bool IsUniqueAgainst(Fido2KeyView fido2View) => fido2View?.RpId != RpId || fido2View?.UserName != UserName;
|
||||
}
|
||||
}
|
||||
8
src/Core/Models/View/ILaunchableView.cs
Normal file
8
src/Core/Models/View/ILaunchableView.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Bit.Core.Models.View
|
||||
{
|
||||
public interface ILaunchableView
|
||||
{
|
||||
bool CanLaunch { get; }
|
||||
string LaunchUri { get; }
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ using Bit.Core.Utilities;
|
||||
|
||||
namespace Bit.Core.Models.View
|
||||
{
|
||||
public class LoginUriView : View
|
||||
public class LoginUriView : View, ILaunchableView
|
||||
{
|
||||
private HashSet<string> _canLaunchWhitelist = new HashSet<string>
|
||||
{
|
||||
|
||||
@@ -20,6 +20,8 @@ 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 string Uri => HasUris ? Uris[0].Uri : null;
|
||||
public string MaskedPassword => Password != null ? "••••••••" : null;
|
||||
public override string SubTitle => Username;
|
||||
|
||||
Reference in New Issue
Block a user