mirror of
https://github.com/bitwarden/mobile
synced 2025-12-10 05:13:31 +00:00
PM-7385 Fix IFido2MakeCredentialConfirmationUserInterface resolve and usage to be constrained to Android. (#3164)
This commit is contained in:
committed by
GitHub
parent
5a4a54f4af
commit
4eb608ec11
@@ -38,7 +38,9 @@ namespace Bit.App
|
|||||||
private readonly IPushNotificationService _pushNotificationService;
|
private readonly IPushNotificationService _pushNotificationService;
|
||||||
private readonly IConfigService _configService;
|
private readonly IConfigService _configService;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private LazyResolve<IFido2MakeCredentialConfirmationUserInterface> _userVerificationMediatorService = new LazyResolve<IFido2MakeCredentialConfirmationUserInterface>();
|
#if ANDROID
|
||||||
|
private LazyResolve<IFido2MakeCredentialConfirmationUserInterface> _fido2MakeCredentialConfirmationUserInterface = new LazyResolve<IFido2MakeCredentialConfirmationUserInterface>();
|
||||||
|
#endif
|
||||||
|
|
||||||
private static bool _isResumed;
|
private static bool _isResumed;
|
||||||
// these variables are static because the app is launching new activities on notification click, creating new instances of App.
|
// these variables are static because the app is launching new activities on notification click, creating new instances of App.
|
||||||
@@ -332,10 +334,12 @@ namespace Bit.App
|
|||||||
|| message.Command == "unlocked"
|
|| message.Command == "unlocked"
|
||||||
|| message.Command == AccountsManagerMessageCommands.ACCOUNT_SWITCH_COMPLETED)
|
|| message.Command == AccountsManagerMessageCommands.ACCOUNT_SWITCH_COMPLETED)
|
||||||
{
|
{
|
||||||
if (message.Command == AccountsManagerMessageCommands.ACCOUNT_SWITCH_COMPLETED && _userVerificationMediatorService.Value.IsConfirmingNewCredential)
|
#if ANDROID
|
||||||
|
if (message.Command == AccountsManagerMessageCommands.ACCOUNT_SWITCH_COMPLETED && _fido2MakeCredentialConfirmationUserInterface.Value.IsConfirmingNewCredential)
|
||||||
{
|
{
|
||||||
_userVerificationMediatorService.Value.OnConfirmationException(new AccountSwitchedException());
|
_fido2MakeCredentialConfirmationUserInterface.Value.OnConfirmationException(new AccountSwitchedException());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
lock (_processingLoginRequestLock)
|
lock (_processingLoginRequestLock)
|
||||||
{
|
{
|
||||||
@@ -720,7 +724,7 @@ namespace Bit.App
|
|||||||
// If we are in background we add the Navigation Actions to a queue to execute when the app resumes.
|
// If we are in background we add the Navigation Actions to a queue to execute when the app resumes.
|
||||||
// Links: https://github.com/dotnet/maui/issues/11501 and https://bitwarden.atlassian.net/wiki/spaces/NMME/pages/664862722/MainPage+Assignments+not+working+on+Android+on+Background+or+App+resume
|
// Links: https://github.com/dotnet/maui/issues/11501 and https://bitwarden.atlassian.net/wiki/spaces/NMME/pages/664862722/MainPage+Assignments+not+working+on+Android+on+Background+or+App+resume
|
||||||
#if ANDROID
|
#if ANDROID
|
||||||
if (_userVerificationMediatorService != null && _userVerificationMediatorService.Value.IsConfirmingNewCredential)
|
if (_fido2MakeCredentialConfirmationUserInterface != null && _fido2MakeCredentialConfirmationUserInterface.Value.IsConfirmingNewCredential)
|
||||||
{
|
{
|
||||||
// if it's creating passkey
|
// if it's creating passkey
|
||||||
// and we have an active pending TaskCompletionSource
|
// and we have an active pending TaskCompletionSource
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ namespace Bit.App.Pages
|
|||||||
private readonly IAutofillHandler _autofillHandler;
|
private readonly IAutofillHandler _autofillHandler;
|
||||||
private readonly IVaultTimeoutService _vaultTimeoutService;
|
private readonly IVaultTimeoutService _vaultTimeoutService;
|
||||||
private readonly IUserVerificationService _userVerificationService;
|
private readonly IUserVerificationService _userVerificationService;
|
||||||
|
#if ANDROID
|
||||||
private readonly LazyResolve<IFido2MakeCredentialConfirmationUserInterface> _fido2MakeCredentialConfirmationUserInterface = new LazyResolve<IFido2MakeCredentialConfirmationUserInterface>();
|
private readonly LazyResolve<IFido2MakeCredentialConfirmationUserInterface> _fido2MakeCredentialConfirmationUserInterface = new LazyResolve<IFido2MakeCredentialConfirmationUserInterface>();
|
||||||
|
#endif
|
||||||
|
|
||||||
private CipherAddEditPageViewModel _vm;
|
private CipherAddEditPageViewModel _vm;
|
||||||
private bool _fromAutofill;
|
private bool _fromAutofill;
|
||||||
@@ -46,7 +48,9 @@ namespace Bit.App.Pages
|
|||||||
_appOptions = appOptions;
|
_appOptions = appOptions;
|
||||||
_fromAutofill = fromAutofill;
|
_fromAutofill = fromAutofill;
|
||||||
FromAutofillFramework = _appOptions?.FromAutofillFramework ?? false;
|
FromAutofillFramework = _appOptions?.FromAutofillFramework ?? false;
|
||||||
|
#if ANDROID
|
||||||
FromAndroidFido2Framework = _fido2MakeCredentialConfirmationUserInterface.Value.IsConfirmingNewCredential;
|
FromAndroidFido2Framework = _fido2MakeCredentialConfirmationUserInterface.Value.IsConfirmingNewCredential;
|
||||||
|
#endif
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_vm = BindingContext as CipherAddEditPageViewModel;
|
_vm = BindingContext as CipherAddEditPageViewModel;
|
||||||
_vm.Page = this;
|
_vm.Page = this;
|
||||||
|
|||||||
@@ -96,7 +96,10 @@ namespace Bit.App.Pages
|
|||||||
_autofillHandler = ServiceContainer.Resolve<IAutofillHandler>();
|
_autofillHandler = ServiceContainer.Resolve<IAutofillHandler>();
|
||||||
_watchDeviceService = ServiceContainer.Resolve<IWatchDeviceService>();
|
_watchDeviceService = ServiceContainer.Resolve<IWatchDeviceService>();
|
||||||
_accountsManager = ServiceContainer.Resolve<IAccountsManager>();
|
_accountsManager = ServiceContainer.Resolve<IAccountsManager>();
|
||||||
_fido2MakeCredentialConfirmationUserInterface = ServiceContainer.Resolve<IFido2MakeCredentialConfirmationUserInterface>();
|
if (ServiceContainer.TryResolve<IFido2MakeCredentialConfirmationUserInterface>(out var fido2MakeService))
|
||||||
|
{
|
||||||
|
_fido2MakeCredentialConfirmationUserInterface = fido2MakeService;
|
||||||
|
}
|
||||||
_userVerificationMediatorService = ServiceContainer.Resolve<IUserVerificationMediatorService>();
|
_userVerificationMediatorService = ServiceContainer.Resolve<IUserVerificationMediatorService>();
|
||||||
|
|
||||||
GeneratePasswordCommand = new Command(GeneratePassword);
|
GeneratePasswordCommand = new Command(GeneratePassword);
|
||||||
@@ -332,7 +335,7 @@ namespace Bit.App.Pages
|
|||||||
public async Task<bool> LoadAsync(AppOptions appOptions = null)
|
public async Task<bool> LoadAsync(AppOptions appOptions = null)
|
||||||
{
|
{
|
||||||
_fromOtp = appOptions?.OtpData != null;
|
_fromOtp = appOptions?.OtpData != null;
|
||||||
IsFromFido2Framework = _fido2MakeCredentialConfirmationUserInterface.IsConfirmingNewCredential;
|
IsFromFido2Framework = _fido2MakeCredentialConfirmationUserInterface?.IsConfirmingNewCredential == true;
|
||||||
|
|
||||||
var myEmail = await _stateService.GetEmailAsync();
|
var myEmail = await _stateService.GetEmailAsync();
|
||||||
OwnershipOptions.Add(new KeyValuePair<string, string>(myEmail, null));
|
OwnershipOptions.Add(new KeyValuePair<string, string>(myEmail, null));
|
||||||
|
|||||||
@@ -22,7 +22,9 @@ 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;
|
||||||
|
#if ANDROID
|
||||||
private readonly LazyResolve<IFido2MakeCredentialConfirmationUserInterface> _fido2MakeCredentialConfirmationUserInterface = new LazyResolve<IFido2MakeCredentialConfirmationUserInterface>();
|
private readonly LazyResolve<IFido2MakeCredentialConfirmationUserInterface> _fido2MakeCredentialConfirmationUserInterface = new LazyResolve<IFido2MakeCredentialConfirmationUserInterface>();
|
||||||
|
#endif
|
||||||
|
|
||||||
private CancellationTokenSource _searchCancellationTokenSource;
|
private CancellationTokenSource _searchCancellationTokenSource;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
@@ -175,11 +177,13 @@ namespace Bit.App.Pages
|
|||||||
|
|
||||||
public async Task SelectCipherAsync(CipherView cipher)
|
public async Task SelectCipherAsync(CipherView cipher)
|
||||||
{
|
{
|
||||||
|
#if ANDROID
|
||||||
if (_fido2MakeCredentialConfirmationUserInterface.Value.IsConfirmingNewCredential)
|
if (_fido2MakeCredentialConfirmationUserInterface.Value.IsConfirmingNewCredential)
|
||||||
{
|
{
|
||||||
await _fido2MakeCredentialConfirmationUserInterface.Value.ConfirmAsync(cipher.Id, cipher.Login.HasFido2Credentials, null);
|
await _fido2MakeCredentialConfirmationUserInterface.Value.ConfirmAsync(cipher.Id, cipher.Login.HasFido2Credentials, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
string selection = null;
|
string selection = null;
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ namespace Bit.App.Utilities.AccountManagement
|
|||||||
private readonly IMessagingService _messagingService;
|
private readonly IMessagingService _messagingService;
|
||||||
private readonly IWatchDeviceService _watchDeviceService;
|
private readonly IWatchDeviceService _watchDeviceService;
|
||||||
private readonly IConditionedAwaiterManager _conditionedAwaiterManager;
|
private readonly IConditionedAwaiterManager _conditionedAwaiterManager;
|
||||||
private LazyResolve<IFido2MakeCredentialConfirmationUserInterface> _userVerificationMediatorService = new LazyResolve<IFido2MakeCredentialConfirmationUserInterface>();
|
#if ANDROID
|
||||||
|
private LazyResolve<IFido2MakeCredentialConfirmationUserInterface> _fido2MakeCredentialConfirmationUserInterface = new LazyResolve<IFido2MakeCredentialConfirmationUserInterface>();
|
||||||
|
#endif
|
||||||
|
|
||||||
Func<AppOptions> _getOptionsFunc;
|
Func<AppOptions> _getOptionsFunc;
|
||||||
private IAccountsManagerHost _accountsManagerHost;
|
private IAccountsManagerHost _accountsManagerHost;
|
||||||
@@ -101,12 +103,14 @@ namespace Bit.App.Utilities.AccountManagement
|
|||||||
{
|
{
|
||||||
_accountsManagerHost.Navigate(NavigationTarget.AddEditCipher);
|
_accountsManagerHost.Navigate(NavigationTarget.AddEditCipher);
|
||||||
}
|
}
|
||||||
else if (_userVerificationMediatorService.Value.IsConfirmingNewCredential)
|
#if ANDROID
|
||||||
|
else if (_fido2MakeCredentialConfirmationUserInterface.Value.IsConfirmingNewCredential)
|
||||||
{
|
{
|
||||||
// If we are already confirming a credential we don't need to navigate again.
|
// If we are already confirming a credential we don't need to navigate again.
|
||||||
// This could happen when switching accounts for example.
|
// This could happen when switching accounts for example.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
else if (Options.FromFido2Framework)
|
else if (Options.FromFido2Framework)
|
||||||
{
|
{
|
||||||
var deviceActionService = Bit.Core.Utilities.ServiceContainer.Resolve<IDeviceActionService>();
|
var deviceActionService = Bit.Core.Utilities.ServiceContainer.Resolve<IDeviceActionService>();
|
||||||
|
|||||||
@@ -432,8 +432,10 @@ namespace Bit.App.Utilities
|
|||||||
// this is called after login in or unlocking so we can assume the vault has been unlocked in this transaction here.
|
// this is called after login in or unlocking so we can assume the vault has been unlocked in this transaction here.
|
||||||
appOptions.HasUnlockedInThisTransaction = true;
|
appOptions.HasUnlockedInThisTransaction = true;
|
||||||
|
|
||||||
var userVerificationMediatorService = ServiceContainer.Resolve<IFido2MakeCredentialConfirmationUserInterface>();
|
#if ANDROID
|
||||||
userVerificationMediatorService.SetCheckHasVaultBeenUnlockedInThisTransaction(() => appOptions?.HasUnlockedInThisTransaction == true);
|
var fido2MakeCredentialConfirmationUserInterface = ServiceContainer.Resolve<IFido2MakeCredentialConfirmationUserInterface>();
|
||||||
|
fido2MakeCredentialConfirmationUserInterface.SetCheckHasVaultBeenUnlockedInThisTransaction(() => appOptions?.HasUnlockedInThisTransaction == true);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (appOptions.FromAutofillFramework && appOptions.SaveType.HasValue)
|
if (appOptions.FromAutofillFramework && appOptions.SaveType.HasValue)
|
||||||
{
|
{
|
||||||
@@ -441,13 +443,15 @@ namespace Bit.App.Utilities
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ANDROID
|
||||||
// If we are waiting for an unlock vault we don't want to trigger 'ExecuteFido2CredentialActionAsync' again,
|
// If we are waiting for an unlock vault we don't want to trigger 'ExecuteFido2CredentialActionAsync' again,
|
||||||
// as it's already running. We just need to 'ConfirmUnlockVault' on the 'userVerificationMediatorService'.
|
// as it's already running. We just need to 'ConfirmUnlockVault' on the 'userVerificationMediatorService'.
|
||||||
if (userVerificationMediatorService.IsWaitingUnlockVault)
|
if (fido2MakeCredentialConfirmationUserInterface.IsWaitingUnlockVault)
|
||||||
{
|
{
|
||||||
userVerificationMediatorService.ConfirmVaultUnlocked();
|
fido2MakeCredentialConfirmationUserInterface.ConfirmVaultUnlocked();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (appOptions.FromFido2Framework && !string.IsNullOrWhiteSpace(appOptions.Fido2CredentialAction))
|
if (appOptions.FromFido2Framework && !string.IsNullOrWhiteSpace(appOptions.Fido2CredentialAction))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user