mirror of
https://github.com/bitwarden/mobile
synced 2025-12-15 07:43:37 +00:00
[PM-7366] Select cipher on search on Fido2 creation (#3154)
* PM-7366 Implemented cipher selection on search on passkey creation * PM-7366 Fix typo
This commit is contained in:
committed by
GitHub
parent
40f036742f
commit
f596f31ffa
@@ -14,6 +14,7 @@ namespace Bit.App.Platforms.Android.Autofill
|
|||||||
private readonly ICipherService _cipherService;
|
private readonly ICipherService _cipherService;
|
||||||
private readonly IUserVerificationMediatorService _userVerificationMediatorService;
|
private readonly IUserVerificationMediatorService _userVerificationMediatorService;
|
||||||
private readonly IDeviceActionService _deviceActionService;
|
private readonly IDeviceActionService _deviceActionService;
|
||||||
|
private readonly IPlatformUtilsService _platformUtilsService;
|
||||||
|
|
||||||
private TaskCompletionSource<(string cipherId, bool? userVerified)> _confirmCredentialTcs;
|
private TaskCompletionSource<(string cipherId, bool? userVerified)> _confirmCredentialTcs;
|
||||||
private Fido2UserVerificationOptions? _currentDefaultUserVerificationOptions;
|
private Fido2UserVerificationOptions? _currentDefaultUserVerificationOptions;
|
||||||
@@ -23,13 +24,15 @@ namespace Bit.App.Platforms.Android.Autofill
|
|||||||
IVaultTimeoutService vaultTimeoutService,
|
IVaultTimeoutService vaultTimeoutService,
|
||||||
ICipherService cipherService,
|
ICipherService cipherService,
|
||||||
IUserVerificationMediatorService userVerificationMediatorService,
|
IUserVerificationMediatorService userVerificationMediatorService,
|
||||||
IDeviceActionService deviceActionService)
|
IDeviceActionService deviceActionService,
|
||||||
|
IPlatformUtilsService platformUtilsService)
|
||||||
{
|
{
|
||||||
_stateService = stateService;
|
_stateService = stateService;
|
||||||
_vaultTimeoutService = vaultTimeoutService;
|
_vaultTimeoutService = vaultTimeoutService;
|
||||||
_cipherService = cipherService;
|
_cipherService = cipherService;
|
||||||
_userVerificationMediatorService = userVerificationMediatorService;
|
_userVerificationMediatorService = userVerificationMediatorService;
|
||||||
_deviceActionService = deviceActionService;
|
_deviceActionService = deviceActionService;
|
||||||
|
_platformUtilsService = platformUtilsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasVaultBeenUnlockedInThisTransaction => _checkHasVaultBeenUnlockedInThisTransaction?.Invoke() == true;
|
public bool HasVaultBeenUnlockedInThisTransaction => _checkHasVaultBeenUnlockedInThisTransaction?.Invoke() == true;
|
||||||
@@ -116,6 +119,22 @@ namespace Bit.App.Platforms.Android.Autofill
|
|||||||
|
|
||||||
public void Confirm(string cipherId, bool? userVerified) => _confirmCredentialTcs?.TrySetResult((cipherId, userVerified));
|
public void Confirm(string cipherId, bool? userVerified) => _confirmCredentialTcs?.TrySetResult((cipherId, userVerified));
|
||||||
|
|
||||||
|
public async Task ConfirmAsync(string cipherId, bool alreadyHasFido2Credential, bool? userVerified)
|
||||||
|
{
|
||||||
|
if (alreadyHasFido2Credential
|
||||||
|
&&
|
||||||
|
!await _platformUtilsService.ShowDialogAsync(
|
||||||
|
AppResources.ThisItemAlreadyContainsAPasskeyAreYouSureYouWantToOverwriteTheCurrentPasskey,
|
||||||
|
AppResources.OverwritePasskey,
|
||||||
|
AppResources.Yes,
|
||||||
|
AppResources.No))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Confirm(cipherId, userVerified);
|
||||||
|
}
|
||||||
|
|
||||||
public void Cancel() => _confirmCredentialTcs?.TrySetCanceled();
|
public void Cancel() => _confirmCredentialTcs?.TrySetCanceled();
|
||||||
|
|
||||||
public void OnConfirmationException(Exception ex) => _confirmCredentialTcs?.TrySetException(ex);
|
public void OnConfirmationException(Exception ex) => _confirmCredentialTcs?.TrySetException(ex);
|
||||||
|
|||||||
@@ -115,7 +115,8 @@ namespace Bit.Droid
|
|||||||
ServiceContainer.Resolve<IVaultTimeoutService>(),
|
ServiceContainer.Resolve<IVaultTimeoutService>(),
|
||||||
ServiceContainer.Resolve<ICipherService>(),
|
ServiceContainer.Resolve<ICipherService>(),
|
||||||
ServiceContainer.Resolve<IUserVerificationMediatorService>(),
|
ServiceContainer.Resolve<IUserVerificationMediatorService>(),
|
||||||
ServiceContainer.Resolve<IDeviceActionService>());
|
ServiceContainer.Resolve<IDeviceActionService>(),
|
||||||
|
ServiceContainer.Resolve<IPlatformUtilsService>());
|
||||||
ServiceContainer.Register<IFido2MakeCredentialConfirmationUserInterface>(fido2MakeCredentialUserInterface);
|
ServiceContainer.Register<IFido2MakeCredentialConfirmationUserInterface>(fido2MakeCredentialUserInterface);
|
||||||
|
|
||||||
var fido2ClientService = new Fido2ClientService(
|
var fido2ClientService = new Fido2ClientService(
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace Bit.Core.Abstractions
|
|||||||
public interface IFido2MakeCredentialConfirmationUserInterface : IFido2MakeCredentialUserInterface
|
public interface IFido2MakeCredentialConfirmationUserInterface : IFido2MakeCredentialUserInterface
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Call this method after the use chose where to save the new Fido2 credential.
|
/// Call this method after the user chose where to save the new Fido2 credential.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="cipherId">
|
/// <param name="cipherId">
|
||||||
/// Cipher ID where to save the new credential.
|
/// Cipher ID where to save the new credential.
|
||||||
@@ -17,6 +17,22 @@ namespace Bit.Core.Abstractions
|
|||||||
/// </param>
|
/// </param>
|
||||||
void Confirm(string cipherId, bool? userVerified);
|
void Confirm(string cipherId, bool? userVerified);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Call this method after the user chose where to save the new Fido2 credential.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cipherId">
|
||||||
|
/// Cipher ID where to save the new credential.
|
||||||
|
/// If <c>null</c> a new default passkey cipher item will be created
|
||||||
|
/// </param>
|
||||||
|
/// <param name="alreadyHasFido2Credential">
|
||||||
|
/// If the cipher corresponding to the <paramref name="cipherId"/> already has a Fido2 credential.
|
||||||
|
/// </param>
|
||||||
|
/// <param name="userVerified">
|
||||||
|
/// Whether the user has been verified or not.
|
||||||
|
/// If <c>null</c> verification has not taken place yet.
|
||||||
|
/// </param>
|
||||||
|
Task ConfirmAsync(string cipherId, bool alreadyHasFido2Credential, bool? userVerified);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Cancels the current flow to make a credential
|
/// Cancels the current flow to make a credential
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ namespace Bit.App.Pages
|
|||||||
{
|
{
|
||||||
if (_appOptions.Fido2CredentialAction == CredentialProviderConstants.Fido2CredentialCreate)
|
if (_appOptions.Fido2CredentialAction == CredentialProviderConstants.Fido2CredentialCreate)
|
||||||
{
|
{
|
||||||
await CreateFido2CredentialIntoAsync(cipher);
|
await _fido2MakeCredentialConfirmationUserInterface.Value.ConfirmAsync(cipher.Id, cipher.Login.HasFido2Credentials, null);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -152,22 +152,6 @@ namespace Bit.App.Pages
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task CreateFido2CredentialIntoAsync(CipherView cipher)
|
|
||||||
{
|
|
||||||
if (cipher.Login.HasFido2Credentials
|
|
||||||
&&
|
|
||||||
!await _platformUtilsService.ShowDialogAsync(
|
|
||||||
AppResources.ThisItemAlreadyContainsAPasskeyAreYouSureYouWantToOverwriteTheCurrentPasskey,
|
|
||||||
AppResources.OverwritePasskey,
|
|
||||||
AppResources.Yes,
|
|
||||||
AppResources.No))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_fido2MakeCredentialConfirmationUserInterface.Value.Confirm(cipher.Id, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override async Task AddFabCipherAsync()
|
protected override async Task AddFabCipherAsync()
|
||||||
{
|
{
|
||||||
//Scenario for creating a new Fido2 credential on Android but showing the Cipher Page
|
//Scenario for creating a new Fido2 credential on Android but showing the Cipher Page
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using Bit.Core.Enums;
|
|||||||
using Bit.Core.Exceptions;
|
using Bit.Core.Exceptions;
|
||||||
using Bit.Core.Models.View;
|
using Bit.Core.Models.View;
|
||||||
using Bit.Core.Utilities;
|
using Bit.Core.Utilities;
|
||||||
|
using Bit.Core.Utilities.Fido2;
|
||||||
|
|
||||||
namespace Bit.App.Pages
|
namespace Bit.App.Pages
|
||||||
{
|
{
|
||||||
@@ -21,6 +22,8 @@ namespace Bit.App.Pages
|
|||||||
private readonly IPasswordRepromptService _passwordRepromptService;
|
private readonly IPasswordRepromptService _passwordRepromptService;
|
||||||
private readonly IOrganizationService _organizationService;
|
private readonly IOrganizationService _organizationService;
|
||||||
private readonly IPolicyService _policyService;
|
private readonly IPolicyService _policyService;
|
||||||
|
private readonly LazyResolve<IFido2MakeCredentialConfirmationUserInterface> _fido2MakeCredentialConfirmationUserInterface = new LazyResolve<IFido2MakeCredentialConfirmationUserInterface>();
|
||||||
|
|
||||||
private CancellationTokenSource _searchCancellationTokenSource;
|
private CancellationTokenSource _searchCancellationTokenSource;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
@@ -172,6 +175,15 @@ namespace Bit.App.Pages
|
|||||||
|
|
||||||
public async Task SelectCipherAsync(CipherView cipher)
|
public async Task SelectCipherAsync(CipherView cipher)
|
||||||
{
|
{
|
||||||
|
if (_appOptions.FromFido2Framework)
|
||||||
|
{
|
||||||
|
if (_appOptions.Fido2CredentialAction == CredentialProviderConstants.Fido2CredentialCreate)
|
||||||
|
{
|
||||||
|
await _fido2MakeCredentialConfirmationUserInterface.Value.ConfirmAsync(cipher.Id, cipher.Login.HasFido2Credentials, null);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
string selection = null;
|
string selection = null;
|
||||||
|
|
||||||
if (!string.IsNullOrWhiteSpace(AutofillUrl))
|
if (!string.IsNullOrWhiteSpace(AutofillUrl))
|
||||||
|
|||||||
Reference in New Issue
Block a user