1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-05 09:01:11 +01:00

Misc fixes for account switching (#1849)

* Misc fixes for account switching

* use unique bio integrity key in ShareExtension
This commit is contained in:
Matt Portune 2022-03-17 14:27:01 -04:00 committed by GitHub
parent 507c3faea1
commit c1748acf39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 30 additions and 14 deletions

View File

@ -943,5 +943,10 @@ namespace Bit.Droid.Services
var activity = CrossCurrentActivity.Current?.Activity as MainActivity;
return activity?.Resources?.Configuration?.FontScale ?? 1;
}
public async Task OnAccountSwitchCompleteAsync()
{
// for any Android-specific cleanup required after switching accounts
}
}
}

View File

@ -46,5 +46,6 @@ namespace Bit.App.Abstractions
void CloseMainApp();
bool SupportsFido2();
float GetSystemFontSizeScale();
Task OnAccountSwitchCompleteAsync();
}
}

View File

@ -428,7 +428,7 @@ namespace Bit.App
});
}
private async Task LockedAsync(string userId, bool autoPromptBiometric)
private async Task LockedAsync(string userId, bool userInitiated)
{
if (!await _stateService.IsActiveAccountAsync(userId))
{
@ -436,6 +436,7 @@ namespace Bit.App
return;
}
var autoPromptBiometric = !userInitiated;
if (autoPromptBiometric && Device.RuntimePlatform == Device.iOS)
{
var vaultTimeout = await _stateService.GetVaultTimeoutAsync();

View File

@ -29,6 +29,8 @@ namespace Bit.App.Services
Constants.iOSAutoFillBiometricIntegrityKey,
Constants.iOSExtensionClearCiphersCacheKey,
Constants.iOSExtensionBiometricIntegrityKey,
Constants.iOSShareExtensionClearCiphersCacheKey,
Constants.iOSShareExtensionBiometricIntegrityKey,
Constants.RememberedEmailKey,
Constants.RememberedOrgIdentifierKey,
};

View File

@ -556,6 +556,8 @@ namespace Bit.App.Utilities
var environmentService = ServiceContainer.Resolve<IEnvironmentService>("environmentService");
await environmentService.SetUrlsFromStorageAsync();
await ClearServiceCacheAsync();
var deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
await deviceActionService.OnAccountSwitchCompleteAsync();
}
public static async Task ClearServiceCacheAsync()

View File

@ -23,6 +23,8 @@
public static string iOSAutoFillBiometricIntegrityKey = "iOSAutoFillBiometricIntegrityState";
public static string iOSExtensionClearCiphersCacheKey = "iOSExtensionClearCiphersCache";
public static string iOSExtensionBiometricIntegrityKey = "iOSExtensionBiometricIntegrityState";
public static string iOSShareExtensionClearCiphersCacheKey = "iOSShareExtensionClearCiphersCache";
public static string iOSShareExtensionBiometricIntegrityKey = "iOSShareExtensionBiometricIntegrityState";
public static string EventCollectionKey = "eventCollection";
public static string RememberedEmailKey = "rememberedEmail";
public static string RememberedOrgIdentifierKey = "rememberedOrgIdentifier";
@ -39,7 +41,8 @@
{
ClearCiphersCacheKey,
iOSAutoFillClearCiphersCacheKey,
iOSExtensionClearCiphersCacheKey
iOSExtensionClearCiphersCacheKey,
iOSShareExtensionClearCiphersCacheKey
};
public static string CiphersKey(string userId) => $"ciphers_{userId}";

View File

@ -594,6 +594,11 @@ namespace Bit.iOS.Core.Services
return scaledHeight / tempHeight;
}
public async Task OnAccountSwitchCompleteAsync()
{
await ASHelpers.ReplaceAllIdentities();
}
public class PickerDelegate : UIDocumentPickerDelegate
{
private readonly DeviceActionService _deviceActionService;

View File

@ -20,11 +20,13 @@ namespace Bit.iOS.Core.Utilities
var timeoutAction = await stateService.GetVaultTimeoutActionAsync();
if (timeoutAction == VaultTimeoutAction.Logout)
{
await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
return;
}
var vaultTimeoutService = ServiceContainer.Resolve<IVaultTimeoutService>("vaultTimeoutService");
if (await vaultTimeoutService.IsLockedAsync())
{
await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
await storageService.SaveAsync(Constants.AutofillNeedsIdentityReplacementKey, true);
return;
}
@ -43,7 +45,9 @@ namespace Bit.iOS.Core.Utilities
{
await ASCredentialIdentityStore.SharedStore?.ReplaceCredentialIdentitiesAsync(identities.ToArray());
await storageService.SaveAsync(Constants.AutofillNeedsIdentityReplacementKey, false);
return;
}
await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
}
}

View File

@ -31,7 +31,7 @@ namespace Bit.iOS.ShareExtension
private NFCNdefReaderSession _nfcSession = null;
private Core.NFCReaderDelegate _nfcDelegate = null;
readonly LazyResolve<IStateService> _stateService = new LazyResolve<IStateService>("stateervice");
readonly LazyResolve<IStateService> _stateService = new LazyResolve<IStateService>("stateService");
readonly LazyResolve<IVaultTimeoutService> _vaultTimeoutService = new LazyResolve<IVaultTimeoutService>("vaultTimeoutService");
readonly LazyResolve<IDeviceActionService> _deviceActionService = new LazyResolve<IDeviceActionService>("deviceActionService");
readonly LazyResolve<IEventService> _eventService = new LazyResolve<IEventService>("eventService");
@ -215,7 +215,7 @@ namespace Bit.iOS.ShareExtension
iOSCoreHelpers.RegisterLocalServices();
var messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
ServiceContainer.Init(_deviceActionService.Value.DeviceUserAgent,
Bit.Core.Constants.iOSExtensionClearCiphersCacheKey, Bit.Core.Constants.iOSAllClearCipherCacheKeys);
Bit.Core.Constants.iOSShareExtensionClearCiphersCacheKey, Bit.Core.Constants.iOSAllClearCipherCacheKeys);
if (!_initedAppCenter)
{
iOSCoreHelpers.RegisterAppCenter();

View File

@ -9,7 +9,7 @@ namespace Bit.iOS.ShareExtension
public LockPasswordViewController(IntPtr handle)
: base(handle)
{
BiometricIntegrityKey = Bit.Core.Constants.iOSExtensionBiometricIntegrityKey;
BiometricIntegrityKey = Bit.Core.Constants.iOSShareExtensionBiometricIntegrityKey;
DismissModalAction = Cancel;
}

View File

@ -146,12 +146,7 @@ namespace Bit.iOS
{
if (_deviceActionService.SystemMajorVersion() >= 12)
{
var extras = message.Data as Tuple<string, bool, bool>;
var userId = extras?.Item1;
var userInitiated = extras?.Item2;
var expired = extras?.Item3;
// TODO make specific to userId
// await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
}
}
else if ((message.Command == "softDeletedCipher" || message.Command == "restoredCipher")
@ -164,9 +159,7 @@ namespace Bit.iOS
var timeoutAction = await _stateService.GetVaultTimeoutActionAsync();
if (timeoutAction == VaultTimeoutAction.Logout)
{
var userId = await _stateService.GetActiveUserIdAsync();
// TODO make specific to userId
// await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
}
else
{