mirror of
https://github.com/bitwarden/mobile
synced 2025-01-28 17:29:18 +01:00
Use secure storage for app id so that it will persist over reinstalls. Use separate app identifier for extension in hockeyapp.
This commit is contained in:
parent
e742fca0e4
commit
9ef840412a
@ -1,38 +1,38 @@
|
|||||||
using System;
|
using System;
|
||||||
using Bit.App.Abstractions;
|
using Bit.App.Abstractions;
|
||||||
using Plugin.Settings.Abstractions;
|
|
||||||
|
|
||||||
namespace Bit.App.Services
|
namespace Bit.App.Services
|
||||||
{
|
{
|
||||||
public class AppIdService : IAppIdService
|
public class AppIdService : IAppIdService
|
||||||
{
|
{
|
||||||
private const string AppIdKey = "appId";
|
private const string AppIdKey = "appId";
|
||||||
private readonly ISettings _settings;
|
private readonly ISecureStorageService _secureStorageService;
|
||||||
private string _appId;
|
private Guid? _appId;
|
||||||
|
|
||||||
public AppIdService(ISettings settings)
|
public AppIdService(ISecureStorageService secureStorageService)
|
||||||
{
|
{
|
||||||
_settings = settings;
|
_secureStorageService = secureStorageService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string AppId
|
public string AppId
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if(!string.IsNullOrWhiteSpace(_appId))
|
if(_appId.HasValue)
|
||||||
{
|
{
|
||||||
return _appId;
|
return _appId.Value.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
_appId = _settings.GetValueOrDefault<string>(AppIdKey);
|
var appIdBytes = _secureStorageService.Retrieve(AppIdKey);
|
||||||
if(!string.IsNullOrWhiteSpace(_appId))
|
if(appIdBytes != null)
|
||||||
{
|
{
|
||||||
return _appId;
|
_appId = new Guid(appIdBytes);
|
||||||
|
return _appId.Value.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
_appId = Guid.NewGuid().ToString();
|
_appId = Guid.NewGuid();
|
||||||
_settings.AddOrUpdateValue(AppIdKey, _appId);
|
_secureStorageService.Store(AppIdKey, _appId.Value.ToByteArray());
|
||||||
return _appId;
|
return _appId.Value.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,31 @@
|
|||||||
using Bit.App.Abstractions;
|
using Bit.App.Abstractions;
|
||||||
using HockeyApp.iOS;
|
using HockeyApp.iOS;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Bit.iOS.Core
|
namespace Bit.iOS.Core
|
||||||
{
|
{
|
||||||
public class HockeyAppCrashManagerDelegate : BITCrashManagerDelegate
|
public class HockeyAppCrashManagerDelegate : BITCrashManagerDelegate
|
||||||
{
|
{
|
||||||
private readonly IAppIdService _appIdService;
|
private readonly IAppIdService _appIdService;
|
||||||
|
private readonly IAuthService _authService;
|
||||||
|
|
||||||
public HockeyAppCrashManagerDelegate(
|
public HockeyAppCrashManagerDelegate(
|
||||||
IAppIdService appIdService)
|
IAppIdService appIdService,
|
||||||
|
IAuthService authService)
|
||||||
{
|
{
|
||||||
_appIdService = appIdService;
|
_appIdService = appIdService;
|
||||||
|
_authService = authService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ApplicationLogForCrashManager(BITCrashManager crashManager)
|
public override string ApplicationLogForCrashManager(BITCrashManager crashManager)
|
||||||
{
|
{
|
||||||
return $"AppId:{_appIdService.AppId}";
|
var log = new
|
||||||
|
{
|
||||||
|
AppId = _appIdService.AppId,
|
||||||
|
UserId = _authService.UserId
|
||||||
|
};
|
||||||
|
|
||||||
|
return JsonConvert.SerializeObject(log, Formatting.Indented);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,10 @@
|
|||||||
<HintPath>..\..\packages\HockeySDK.Xamarin.4.1.0-beta3\lib\Xamarin.iOS10\HockeySDK.iOSBindings.dll</HintPath>
|
<HintPath>..\..\packages\HockeySDK.Xamarin.4.1.0-beta3\lib\Xamarin.iOS10\HockeySDK.iOSBindings.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
|
||||||
|
<Private>True</Private>
|
||||||
|
</Reference>
|
||||||
<Reference Include="Plugin.Settings, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="Plugin.Settings, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\..\packages\Xam.Plugins.Settings.2.1.0\lib\Xamarin.iOS10\Plugin.Settings.dll</HintPath>
|
<HintPath>..\..\packages\Xam.Plugins.Settings.2.1.0\lib\Xamarin.iOS10\Plugin.Settings.dll</HintPath>
|
||||||
<Private>True</Private>
|
<Private>True</Private>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<packages>
|
||||||
<package id="HockeySDK.Xamarin" version="4.1.0-beta3" targetFramework="xamarinios10" />
|
<package id="HockeySDK.Xamarin" version="4.1.0-beta3" targetFramework="xamarinios10" />
|
||||||
|
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="xamarinios10" />
|
||||||
<package id="sqlite-net-pcl" version="1.1.2" targetFramework="xamarinios10" />
|
<package id="sqlite-net-pcl" version="1.1.2" targetFramework="xamarinios10" />
|
||||||
<package id="SQLitePCL.bundle_green" version="0.9.2" targetFramework="xamarinios10" />
|
<package id="SQLitePCL.bundle_green" version="0.9.2" targetFramework="xamarinios10" />
|
||||||
<package id="SQLitePCL.raw" version="0.9.2" targetFramework="xamarinios10" />
|
<package id="SQLitePCL.raw" version="0.9.2" targetFramework="xamarinios10" />
|
||||||
|
@ -46,10 +46,13 @@ namespace Bit.iOS.Extension
|
|||||||
|
|
||||||
if(!_setupHockeyApp)
|
if(!_setupHockeyApp)
|
||||||
{
|
{
|
||||||
var crashManagerDelegate = new HockeyAppCrashManagerDelegate(Resolver.Resolve<IAppIdService>());
|
var appIdService = Resolver.Resolve<IAppIdService>();
|
||||||
|
var crashManagerDelegate = new HockeyAppCrashManagerDelegate(
|
||||||
|
appIdService, Resolver.Resolve<IAuthService>());
|
||||||
var manager = HockeyApp.iOS.BITHockeyManager.SharedHockeyManager;
|
var manager = HockeyApp.iOS.BITHockeyManager.SharedHockeyManager;
|
||||||
manager.Configure("51f96ae568ba45f699a18ad9f63046c3", crashManagerDelegate);
|
manager.Configure("bff5b1d2b6554472b91555a0d4704d4c", crashManagerDelegate);
|
||||||
manager.CrashManager.CrashManagerStatus = HockeyApp.iOS.BITCrashManagerStatus.AutoSend;
|
manager.CrashManager.CrashManagerStatus = HockeyApp.iOS.BITCrashManagerStatus.AutoSend;
|
||||||
|
manager.UserId = appIdService.AppId;
|
||||||
manager.StartManager();
|
manager.StartManager();
|
||||||
manager.Authenticator.AuthenticateInstallation();
|
manager.Authenticator.AuthenticateInstallation();
|
||||||
_setupHockeyApp = true;
|
_setupHockeyApp = true;
|
||||||
|
@ -18,7 +18,6 @@ using Plugin.Fingerprint.Abstractions;
|
|||||||
using Plugin.Settings.Abstractions;
|
using Plugin.Settings.Abstractions;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Xamarin.Forms;
|
using Xamarin.Forms;
|
||||||
using Bit.App;
|
|
||||||
using Bit.iOS.Core.Services;
|
using Bit.iOS.Core.Services;
|
||||||
using PushNotification.Plugin;
|
using PushNotification.Plugin;
|
||||||
using Plugin.DeviceInfo;
|
using Plugin.DeviceInfo;
|
||||||
@ -44,10 +43,13 @@ namespace Bit.iOS
|
|||||||
SetIoc();
|
SetIoc();
|
||||||
}
|
}
|
||||||
|
|
||||||
var crashManagerDelegate = new HockeyAppCrashManagerDelegate(Resolver.Resolve<IAppIdService>());
|
var appIdService = Resolver.Resolve<IAppIdService>();
|
||||||
|
var crashManagerDelegate = new HockeyAppCrashManagerDelegate(
|
||||||
|
appIdService, Resolver.Resolve<IAuthService>());
|
||||||
var manager = BITHockeyManager.SharedHockeyManager;
|
var manager = BITHockeyManager.SharedHockeyManager;
|
||||||
manager.Configure("51f96ae568ba45f699a18ad9f63046c3", crashManagerDelegate);
|
manager.Configure("51f96ae568ba45f699a18ad9f63046c3", crashManagerDelegate);
|
||||||
manager.CrashManager.CrashManagerStatus = BITCrashManagerStatus.AutoSend;
|
manager.CrashManager.CrashManagerStatus = BITCrashManagerStatus.AutoSend;
|
||||||
|
manager.UserId = appIdService.AppId;
|
||||||
manager.StartManager();
|
manager.StartManager();
|
||||||
manager.Authenticator.AuthenticateInstallation();
|
manager.Authenticator.AuthenticateInstallation();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user