mirror of
https://github.com/bitwarden/mobile.git
synced 2024-12-28 17:18:23 +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:
parent
507c3faea1
commit
c1748acf39
@ -943,5 +943,10 @@ namespace Bit.Droid.Services
|
|||||||
var activity = CrossCurrentActivity.Current?.Activity as MainActivity;
|
var activity = CrossCurrentActivity.Current?.Activity as MainActivity;
|
||||||
return activity?.Resources?.Configuration?.FontScale ?? 1;
|
return activity?.Resources?.Configuration?.FontScale ?? 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task OnAccountSwitchCompleteAsync()
|
||||||
|
{
|
||||||
|
// for any Android-specific cleanup required after switching accounts
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,5 +46,6 @@ namespace Bit.App.Abstractions
|
|||||||
void CloseMainApp();
|
void CloseMainApp();
|
||||||
bool SupportsFido2();
|
bool SupportsFido2();
|
||||||
float GetSystemFontSizeScale();
|
float GetSystemFontSizeScale();
|
||||||
|
Task OnAccountSwitchCompleteAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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))
|
if (!await _stateService.IsActiveAccountAsync(userId))
|
||||||
{
|
{
|
||||||
@ -436,6 +436,7 @@ namespace Bit.App
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var autoPromptBiometric = !userInitiated;
|
||||||
if (autoPromptBiometric && Device.RuntimePlatform == Device.iOS)
|
if (autoPromptBiometric && Device.RuntimePlatform == Device.iOS)
|
||||||
{
|
{
|
||||||
var vaultTimeout = await _stateService.GetVaultTimeoutAsync();
|
var vaultTimeout = await _stateService.GetVaultTimeoutAsync();
|
||||||
|
@ -29,6 +29,8 @@ namespace Bit.App.Services
|
|||||||
Constants.iOSAutoFillBiometricIntegrityKey,
|
Constants.iOSAutoFillBiometricIntegrityKey,
|
||||||
Constants.iOSExtensionClearCiphersCacheKey,
|
Constants.iOSExtensionClearCiphersCacheKey,
|
||||||
Constants.iOSExtensionBiometricIntegrityKey,
|
Constants.iOSExtensionBiometricIntegrityKey,
|
||||||
|
Constants.iOSShareExtensionClearCiphersCacheKey,
|
||||||
|
Constants.iOSShareExtensionBiometricIntegrityKey,
|
||||||
Constants.RememberedEmailKey,
|
Constants.RememberedEmailKey,
|
||||||
Constants.RememberedOrgIdentifierKey,
|
Constants.RememberedOrgIdentifierKey,
|
||||||
};
|
};
|
||||||
|
@ -556,6 +556,8 @@ namespace Bit.App.Utilities
|
|||||||
var environmentService = ServiceContainer.Resolve<IEnvironmentService>("environmentService");
|
var environmentService = ServiceContainer.Resolve<IEnvironmentService>("environmentService");
|
||||||
await environmentService.SetUrlsFromStorageAsync();
|
await environmentService.SetUrlsFromStorageAsync();
|
||||||
await ClearServiceCacheAsync();
|
await ClearServiceCacheAsync();
|
||||||
|
var deviceActionService = ServiceContainer.Resolve<IDeviceActionService>("deviceActionService");
|
||||||
|
await deviceActionService.OnAccountSwitchCompleteAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task ClearServiceCacheAsync()
|
public static async Task ClearServiceCacheAsync()
|
||||||
|
@ -23,6 +23,8 @@
|
|||||||
public static string iOSAutoFillBiometricIntegrityKey = "iOSAutoFillBiometricIntegrityState";
|
public static string iOSAutoFillBiometricIntegrityKey = "iOSAutoFillBiometricIntegrityState";
|
||||||
public static string iOSExtensionClearCiphersCacheKey = "iOSExtensionClearCiphersCache";
|
public static string iOSExtensionClearCiphersCacheKey = "iOSExtensionClearCiphersCache";
|
||||||
public static string iOSExtensionBiometricIntegrityKey = "iOSExtensionBiometricIntegrityState";
|
public static string iOSExtensionBiometricIntegrityKey = "iOSExtensionBiometricIntegrityState";
|
||||||
|
public static string iOSShareExtensionClearCiphersCacheKey = "iOSShareExtensionClearCiphersCache";
|
||||||
|
public static string iOSShareExtensionBiometricIntegrityKey = "iOSShareExtensionBiometricIntegrityState";
|
||||||
public static string EventCollectionKey = "eventCollection";
|
public static string EventCollectionKey = "eventCollection";
|
||||||
public static string RememberedEmailKey = "rememberedEmail";
|
public static string RememberedEmailKey = "rememberedEmail";
|
||||||
public static string RememberedOrgIdentifierKey = "rememberedOrgIdentifier";
|
public static string RememberedOrgIdentifierKey = "rememberedOrgIdentifier";
|
||||||
@ -39,7 +41,8 @@
|
|||||||
{
|
{
|
||||||
ClearCiphersCacheKey,
|
ClearCiphersCacheKey,
|
||||||
iOSAutoFillClearCiphersCacheKey,
|
iOSAutoFillClearCiphersCacheKey,
|
||||||
iOSExtensionClearCiphersCacheKey
|
iOSExtensionClearCiphersCacheKey,
|
||||||
|
iOSShareExtensionClearCiphersCacheKey
|
||||||
};
|
};
|
||||||
|
|
||||||
public static string CiphersKey(string userId) => $"ciphers_{userId}";
|
public static string CiphersKey(string userId) => $"ciphers_{userId}";
|
||||||
|
@ -594,6 +594,11 @@ namespace Bit.iOS.Core.Services
|
|||||||
return scaledHeight / tempHeight;
|
return scaledHeight / tempHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task OnAccountSwitchCompleteAsync()
|
||||||
|
{
|
||||||
|
await ASHelpers.ReplaceAllIdentities();
|
||||||
|
}
|
||||||
|
|
||||||
public class PickerDelegate : UIDocumentPickerDelegate
|
public class PickerDelegate : UIDocumentPickerDelegate
|
||||||
{
|
{
|
||||||
private readonly DeviceActionService _deviceActionService;
|
private readonly DeviceActionService _deviceActionService;
|
||||||
|
@ -20,11 +20,13 @@ namespace Bit.iOS.Core.Utilities
|
|||||||
var timeoutAction = await stateService.GetVaultTimeoutActionAsync();
|
var timeoutAction = await stateService.GetVaultTimeoutActionAsync();
|
||||||
if (timeoutAction == VaultTimeoutAction.Logout)
|
if (timeoutAction == VaultTimeoutAction.Logout)
|
||||||
{
|
{
|
||||||
|
await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var vaultTimeoutService = ServiceContainer.Resolve<IVaultTimeoutService>("vaultTimeoutService");
|
var vaultTimeoutService = ServiceContainer.Resolve<IVaultTimeoutService>("vaultTimeoutService");
|
||||||
if (await vaultTimeoutService.IsLockedAsync())
|
if (await vaultTimeoutService.IsLockedAsync())
|
||||||
{
|
{
|
||||||
|
await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
|
||||||
await storageService.SaveAsync(Constants.AutofillNeedsIdentityReplacementKey, true);
|
await storageService.SaveAsync(Constants.AutofillNeedsIdentityReplacementKey, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -43,7 +45,9 @@ namespace Bit.iOS.Core.Utilities
|
|||||||
{
|
{
|
||||||
await ASCredentialIdentityStore.SharedStore?.ReplaceCredentialIdentitiesAsync(identities.ToArray());
|
await ASCredentialIdentityStore.SharedStore?.ReplaceCredentialIdentitiesAsync(identities.ToArray());
|
||||||
await storageService.SaveAsync(Constants.AutofillNeedsIdentityReplacementKey, false);
|
await storageService.SaveAsync(Constants.AutofillNeedsIdentityReplacementKey, false);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ namespace Bit.iOS.ShareExtension
|
|||||||
private NFCNdefReaderSession _nfcSession = null;
|
private NFCNdefReaderSession _nfcSession = null;
|
||||||
private Core.NFCReaderDelegate _nfcDelegate = 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<IVaultTimeoutService> _vaultTimeoutService = new LazyResolve<IVaultTimeoutService>("vaultTimeoutService");
|
||||||
readonly LazyResolve<IDeviceActionService> _deviceActionService = new LazyResolve<IDeviceActionService>("deviceActionService");
|
readonly LazyResolve<IDeviceActionService> _deviceActionService = new LazyResolve<IDeviceActionService>("deviceActionService");
|
||||||
readonly LazyResolve<IEventService> _eventService = new LazyResolve<IEventService>("eventService");
|
readonly LazyResolve<IEventService> _eventService = new LazyResolve<IEventService>("eventService");
|
||||||
@ -215,7 +215,7 @@ namespace Bit.iOS.ShareExtension
|
|||||||
iOSCoreHelpers.RegisterLocalServices();
|
iOSCoreHelpers.RegisterLocalServices();
|
||||||
var messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
|
var messagingService = ServiceContainer.Resolve<IMessagingService>("messagingService");
|
||||||
ServiceContainer.Init(_deviceActionService.Value.DeviceUserAgent,
|
ServiceContainer.Init(_deviceActionService.Value.DeviceUserAgent,
|
||||||
Bit.Core.Constants.iOSExtensionClearCiphersCacheKey, Bit.Core.Constants.iOSAllClearCipherCacheKeys);
|
Bit.Core.Constants.iOSShareExtensionClearCiphersCacheKey, Bit.Core.Constants.iOSAllClearCipherCacheKeys);
|
||||||
if (!_initedAppCenter)
|
if (!_initedAppCenter)
|
||||||
{
|
{
|
||||||
iOSCoreHelpers.RegisterAppCenter();
|
iOSCoreHelpers.RegisterAppCenter();
|
||||||
|
@ -9,7 +9,7 @@ namespace Bit.iOS.ShareExtension
|
|||||||
public LockPasswordViewController(IntPtr handle)
|
public LockPasswordViewController(IntPtr handle)
|
||||||
: base(handle)
|
: base(handle)
|
||||||
{
|
{
|
||||||
BiometricIntegrityKey = Bit.Core.Constants.iOSExtensionBiometricIntegrityKey;
|
BiometricIntegrityKey = Bit.Core.Constants.iOSShareExtensionBiometricIntegrityKey;
|
||||||
DismissModalAction = Cancel;
|
DismissModalAction = Cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,12 +146,7 @@ namespace Bit.iOS
|
|||||||
{
|
{
|
||||||
if (_deviceActionService.SystemMajorVersion() >= 12)
|
if (_deviceActionService.SystemMajorVersion() >= 12)
|
||||||
{
|
{
|
||||||
var extras = message.Data as Tuple<string, bool, bool>;
|
await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
|
||||||
var userId = extras?.Item1;
|
|
||||||
var userInitiated = extras?.Item2;
|
|
||||||
var expired = extras?.Item3;
|
|
||||||
// TODO make specific to userId
|
|
||||||
// await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((message.Command == "softDeletedCipher" || message.Command == "restoredCipher")
|
else if ((message.Command == "softDeletedCipher" || message.Command == "restoredCipher")
|
||||||
@ -164,9 +159,7 @@ namespace Bit.iOS
|
|||||||
var timeoutAction = await _stateService.GetVaultTimeoutActionAsync();
|
var timeoutAction = await _stateService.GetVaultTimeoutActionAsync();
|
||||||
if (timeoutAction == VaultTimeoutAction.Logout)
|
if (timeoutAction == VaultTimeoutAction.Logout)
|
||||||
{
|
{
|
||||||
var userId = await _stateService.GetActiveUserIdAsync();
|
await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
|
||||||
// TODO make specific to userId
|
|
||||||
// await ASCredentialIdentityStore.SharedStore?.RemoveAllCredentialIdentitiesAsync();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user