mirror of
https://github.com/bitwarden/mobile.git
synced 2024-06-25 10:26:02 +02: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:
parent
40f036742f
commit
f596f31ffa
|
@ -14,7 +14,8 @@ namespace Bit.App.Platforms.Android.Autofill
|
|||
private readonly ICipherService _cipherService;
|
||||
private readonly IUserVerificationMediatorService _userVerificationMediatorService;
|
||||
private readonly IDeviceActionService _deviceActionService;
|
||||
|
||||
private readonly IPlatformUtilsService _platformUtilsService;
|
||||
|
||||
private TaskCompletionSource<(string cipherId, bool? userVerified)> _confirmCredentialTcs;
|
||||
private Fido2UserVerificationOptions? _currentDefaultUserVerificationOptions;
|
||||
private Func<bool> _checkHasVaultBeenUnlockedInThisTransaction;
|
||||
|
@ -23,13 +24,15 @@ namespace Bit.App.Platforms.Android.Autofill
|
|||
IVaultTimeoutService vaultTimeoutService,
|
||||
ICipherService cipherService,
|
||||
IUserVerificationMediatorService userVerificationMediatorService,
|
||||
IDeviceActionService deviceActionService)
|
||||
IDeviceActionService deviceActionService,
|
||||
IPlatformUtilsService platformUtilsService)
|
||||
{
|
||||
_stateService = stateService;
|
||||
_vaultTimeoutService = vaultTimeoutService;
|
||||
_cipherService = cipherService;
|
||||
_userVerificationMediatorService = userVerificationMediatorService;
|
||||
_deviceActionService = deviceActionService;
|
||||
_platformUtilsService = platformUtilsService;
|
||||
}
|
||||
|
||||
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 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 OnConfirmationException(Exception ex) => _confirmCredentialTcs?.TrySetException(ex);
|
||||
|
|
|
@ -115,7 +115,8 @@ namespace Bit.Droid
|
|||
ServiceContainer.Resolve<IVaultTimeoutService>(),
|
||||
ServiceContainer.Resolve<ICipherService>(),
|
||||
ServiceContainer.Resolve<IUserVerificationMediatorService>(),
|
||||
ServiceContainer.Resolve<IDeviceActionService>());
|
||||
ServiceContainer.Resolve<IDeviceActionService>(),
|
||||
ServiceContainer.Resolve<IPlatformUtilsService>());
|
||||
ServiceContainer.Register<IFido2MakeCredentialConfirmationUserInterface>(fido2MakeCredentialUserInterface);
|
||||
|
||||
var fido2ClientService = new Fido2ClientService(
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace Bit.Core.Abstractions
|
|||
public interface IFido2MakeCredentialConfirmationUserInterface : IFido2MakeCredentialUserInterface
|
||||
{
|
||||
/// <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>
|
||||
/// <param name="cipherId">
|
||||
/// Cipher ID where to save the new credential.
|
||||
|
@ -17,6 +17,22 @@ namespace Bit.Core.Abstractions
|
|||
/// </param>
|
||||
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>
|
||||
/// Cancels the current flow to make a credential
|
||||
/// </summary>
|
||||
|
|
|
@ -95,7 +95,7 @@ namespace Bit.App.Pages
|
|||
{
|
||||
if (_appOptions.Fido2CredentialAction == CredentialProviderConstants.Fido2CredentialCreate)
|
||||
{
|
||||
await CreateFido2CredentialIntoAsync(cipher);
|
||||
await _fido2MakeCredentialConfirmationUserInterface.Value.ConfirmAsync(cipher.Id, cipher.Login.HasFido2Credentials, null);
|
||||
}
|
||||
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()
|
||||
{
|
||||
//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.Models.View;
|
||||
using Bit.Core.Utilities;
|
||||
using Bit.Core.Utilities.Fido2;
|
||||
|
||||
namespace Bit.App.Pages
|
||||
{
|
||||
|
@ -21,6 +22,8 @@ namespace Bit.App.Pages
|
|||
private readonly IPasswordRepromptService _passwordRepromptService;
|
||||
private readonly IOrganizationService _organizationService;
|
||||
private readonly IPolicyService _policyService;
|
||||
private readonly LazyResolve<IFido2MakeCredentialConfirmationUserInterface> _fido2MakeCredentialConfirmationUserInterface = new LazyResolve<IFido2MakeCredentialConfirmationUserInterface>();
|
||||
|
||||
private CancellationTokenSource _searchCancellationTokenSource;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
|
@ -172,6 +175,15 @@ namespace Bit.App.Pages
|
|||
|
||||
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;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(AutofillUrl))
|
||||
|
|
Loading…
Reference in New Issue
Block a user