1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-21 18:53:29 +00:00

Merge branch 'master' into feature/maui-migration

Fixed conflicts and added null check on ForwardEmailDomainName

# Conflicts:
#	src/Core/Pages/Vault/CipherAddEditPage.xaml
#	src/Core/Pages/Vault/CipherDetailsPage.xaml
#	src/iOS.Core/Renderers/CollectionView/ExtendedGroupableItemsViewController.cs
This commit is contained in:
Dinis Vieira
2023-11-05 23:59:30 +00:00
124 changed files with 7786 additions and 2159 deletions

View File

@@ -1,14 +1,15 @@
using Bit.Core.Models.Domain;
using System;
using Bit.Core.Models.Domain;
namespace Bit.Core.Models.Api
{
public class Fido2KeyApi
public class Fido2CredentialApi
{
public Fido2KeyApi()
public Fido2CredentialApi()
{
}
public Fido2KeyApi(Fido2Key fido2Key)
public Fido2CredentialApi(Fido2Credential fido2Key)
{
CredentialId = fido2Key.CredentialId?.EncryptedString;
Discoverable = fido2Key.Discoverable?.EncryptedString;
@@ -21,18 +22,20 @@ namespace Bit.Core.Models.Api
UserHandle = fido2Key.UserHandle?.EncryptedString;
UserName = fido2Key.UserName?.EncryptedString;
Counter = fido2Key.Counter?.EncryptedString;
CreationDate = fido2Key.CreationDate;
}
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;
public string KeyType { get; set; } = Constants.DefaultFido2CredentialType;
public string KeyAlgorithm { get; set; } = Constants.DefaultFido2CredentialAlgorithm;
public string KeyCurve { get; set; } = Constants.DefaultFido2CredentialCurve;
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 DateTime CreationDate { get; set; }
}
}

View File

@@ -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 List<Fido2KeyApi> Fido2Keys { get; set; }
public List<Fido2CredentialApi> Fido2Credentials { get; set; }
}
}

View File

@@ -1,12 +1,13 @@
using Bit.Core.Models.Api;
using System;
using Bit.Core.Models.Api;
namespace Bit.Core.Models.Data
{
public class Fido2KeyData : Data
public class Fido2CredentialData : Data
{
public Fido2KeyData() { }
public Fido2CredentialData() { }
public Fido2KeyData(Fido2KeyApi apiData)
public Fido2CredentialData(Fido2CredentialApi apiData)
{
CredentialId = apiData.CredentialId;
Discoverable = apiData.Discoverable;
@@ -19,18 +20,20 @@ namespace Bit.Core.Models.Data
UserHandle = apiData.UserHandle;
UserName = apiData.UserName;
Counter = apiData.Counter;
CreationDate = apiData.CreationDate;
}
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;
public string KeyType { get; set; } = Constants.DefaultFido2CredentialType;
public string KeyAlgorithm { get; set; } = Constants.DefaultFido2CredentialAlgorithm;
public string KeyCurve { get; set; } = Constants.DefaultFido2CredentialCurve;
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 DateTime CreationDate { get; set; }
}
}

View File

@@ -16,7 +16,7 @@ namespace Bit.Core.Models.Data
PasswordRevisionDate = data.PasswordRevisionDate;
Totp = data.Totp;
Uris = data.Uris?.Select(u => new LoginUriData(u)).ToList();
Fido2Keys = data.Fido2Keys?.Select(f => new Fido2KeyData(f)).ToList();
Fido2Credentials = data.Fido2Credentials?.Select(f => new Fido2CredentialData(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 List<Fido2KeyData> Fido2Keys { get; set; }
public List<Fido2CredentialData> Fido2Credentials { get; set; }
}
}

View File

@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Bit.Core.Models.Data;
using Bit.Core.Models.View;
namespace Bit.Core.Models.Domain
{
public class Fido2Credential : Domain
{
public static HashSet<string> EncryptablePropertiesToMap => new HashSet<string>
{
nameof(CredentialId),
nameof(Discoverable),
nameof(KeyType),
nameof(KeyAlgorithm),
nameof(KeyCurve),
nameof(KeyValue),
nameof(RpId),
nameof(RpName),
nameof(UserHandle),
nameof(UserName),
nameof(Counter)
};
public static HashSet<string> NonEncryptablePropertiesToMap => new HashSet<string>
{
nameof(CreationDate)
};
public static HashSet<string> AllPropertiesToMap => new HashSet<string>(EncryptablePropertiesToMap.Concat(NonEncryptablePropertiesToMap));
public Fido2Credential() { }
public Fido2Credential(Fido2CredentialData data, bool alreadyEncrypted = false)
{
BuildDomainModel(this, data, AllPropertiesToMap, alreadyEncrypted, NonEncryptablePropertiesToMap);
}
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; }
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 DateTime CreationDate { get; set; }
public async Task<Fido2CredentialView> DecryptAsync(string orgId, SymmetricCryptoKey key = null)
{
return await DecryptObjAsync(new Fido2CredentialView(this), this, EncryptablePropertiesToMap, orgId, key);
}
public Fido2CredentialData ToFido2CredentialData()
{
var data = new Fido2CredentialData();
BuildDataModel(this, data, AllPropertiesToMap, NonEncryptablePropertiesToMap);
return data;
}
}
}

View File

@@ -1,56 +0,0 @@
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(CredentialId),
nameof(Discoverable),
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 CredentialId { get; set; }
public EncString Discoverable { 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, SymmetricCryptoKey key = null)
{
return await DecryptObjAsync(new Fido2KeyView(), this, EncryptableProperties, orgId, key);
}
public Fido2KeyData ToFido2KeyData()
{
var data = new Fido2KeyData();
BuildDataModel(this, data, EncryptableProperties);
return data;
}
}
}

View File

@@ -15,7 +15,7 @@ namespace Bit.Core.Models.Domain
{
PasswordRevisionDate = obj.PasswordRevisionDate;
Uris = obj.Uris?.Select(u => new LoginUri(u, alreadyEncrypted)).ToList();
Fido2Keys = obj.Fido2Keys?.Select(f => new Fido2Key(f, alreadyEncrypted)).ToList();
Fido2Credentials = obj.Fido2Credentials?.Select(f => new Fido2Credential(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 List<Fido2Key> Fido2Keys { get; set; }
public List<Fido2Credential> Fido2Credentials { get; set; }
public async Task<LoginView> DecryptAsync(string orgId, SymmetricCryptoKey key = null)
{
@@ -47,12 +47,12 @@ namespace Bit.Core.Models.Domain
view.Uris.Add(await uri.DecryptAsync(orgId, key));
}
}
if (Fido2Keys != null)
if (Fido2Credentials != null)
{
view.Fido2Keys = new List<Fido2KeyView>();
foreach (var fido2Key in Fido2Keys)
view.Fido2Credentials = new List<Fido2CredentialView>();
foreach (var fido2Credential in Fido2Credentials)
{
view.Fido2Keys.Add(await fido2Key.DecryptAsync(orgId, key));
view.Fido2Credentials.Add(await fido2Credential.DecryptAsync(orgId, key));
}
}
return view;
@@ -72,9 +72,9 @@ namespace Bit.Core.Models.Domain
{
l.Uris = Uris.Select(u => u.ToLoginUriData()).ToList();
}
if (Fido2Keys != null)
if (Fido2Credentials != null)
{
l.Fido2Keys = Fido2Keys.Select(f => f.ToFido2KeyData()).ToList();
l.Fido2Credentials = Fido2Credentials.Select(f => f.ToFido2CredentialData()).ToList();
}
return l;
}

View File

@@ -24,6 +24,8 @@ namespace Bit.Core.Models.Domain
public string FastMailApiKey { get; set; }
public string AnonAddyApiAccessToken { get; set; }
public string AnonAddyDomainName { get; set; }
public string ForwardEmailApiAccessToken { get; set; }
public string ForwardEmailDomainName { get; set; }
public string EmailWebsite { get; set; }
public ForwarderOptions GetForwarderOptions()
@@ -49,6 +51,12 @@ namespace Bit.Core.Models.Domain
return new ForwarderOptions { ApiKey = FirefoxRelayApiAccessToken };
case ForwardedEmailServiceType.SimpleLogin:
return new ForwarderOptions { ApiKey = SimpleLoginApiKey };
case ForwardedEmailServiceType.ForwardEmail:
return new ForwardEmailForwarderOptions
{
ApiKey = ForwardEmailApiAccessToken,
DomainName = ForwardEmailDomainName
};
default:
return null;
}

View File

@@ -32,7 +32,7 @@ namespace Bit.Core.Models.Request
Password = cipher.Login.Password?.EncryptedString,
PasswordRevisionDate = cipher.Login.PasswordRevisionDate,
Totp = cipher.Login.Totp?.EncryptedString,
Fido2Keys = cipher.Login.Fido2Keys?.Select(f => new Fido2KeyApi(f)).ToList()
Fido2Credentials = cipher.Login.Fido2Credentials?.Select(f => new Fido2CredentialApi(f)).ToList()
};
break;
case CipherType.Card:

View File

@@ -121,6 +121,6 @@ namespace Bit.Core.Models.View
public bool IsClonable => OrganizationId is null;
public bool HasFido2Key => Type == CipherType.Login && Login?.HasFido2Keys == true;
public bool HasFido2Credential => Type == CipherType.Login && Login?.HasFido2Credentials == true;
}
}

View File

@@ -1,21 +1,33 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using Bit.Core.Enums;
using Bit.Core.Models.Domain;
namespace Bit.Core.Models.View
{
public class Fido2KeyView : ItemView, ILaunchableView
public class Fido2CredentialView : ItemView, ILaunchableView
{
public Fido2CredentialView()
{
}
public Fido2CredentialView(Fido2Credential fido2Credential)
{
CreationDate = fido2Credential.CreationDate;
}
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;
public string KeyType { get; set; } = Constants.DefaultFido2CredentialType;
public string KeyAlgorithm { get; set; } = Constants.DefaultFido2CredentialAlgorithm;
public string KeyCurve { get; set; } = Constants.DefaultFido2CredentialCurve;
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 DateTime CreationDate { get; set; }
public override string SubTitle => UserName;
public override List<KeyValuePair<string, LinkedIdType>> LinkedFieldOptions => new List<KeyValuePair<string, LinkedIdType>>();
@@ -23,6 +35,6 @@ namespace Bit.Core.Models.View
public bool CanLaunch => !string.IsNullOrEmpty(RpId);
public string LaunchUri => $"https://{RpId}";
public bool IsUniqueAgainst(Fido2KeyView fido2View) => fido2View?.RpId != RpId || fido2View?.UserName != UserName;
public bool IsUniqueAgainst(Fido2CredentialView fido2View) => fido2View?.RpId != RpId || fido2View?.UserName != UserName;
}
}

View File

@@ -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 List<Fido2KeyView> Fido2Keys { get; set; }
public List<Fido2CredentialView> Fido2Credentials { get; set; }
public string Uri => HasUris ? Uris[0].Uri : null;
public string MaskedPassword => Password != null ? "••••••••" : null;
@@ -28,8 +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 bool HasFido2Credentials => Fido2Credentials?.Any() == true;
public Fido2CredentialView MainFido2Credential => HasFido2Credentials ? Fido2Credentials[0] : null;
public override List<KeyValuePair<string, LinkedIdType>> LinkedFieldOptions
{