mirror of
https://github.com/bitwarden/android.git
synced 2024-12-18 23:31:52 +03:00
access group for keychain. load sites for given hostname in extension
This commit is contained in:
parent
9d8f54af9d
commit
1307b6a1b2
12 changed files with 104 additions and 22 deletions
|
@ -4,7 +4,7 @@ using Bit.App.Abstractions;
|
|||
using Foundation;
|
||||
using Security;
|
||||
|
||||
namespace Bit.iOS.Services
|
||||
namespace Bit.iOS.Core.Services
|
||||
{
|
||||
public class KeyChainStorageService : ISecureStorageService
|
||||
{
|
||||
|
@ -67,7 +67,8 @@ namespace Bit.iOS.Services
|
|||
var record = new SecRecord(SecKind.GenericPassword)
|
||||
{
|
||||
Service = NSBundle.MainBundle.BundleIdentifier,
|
||||
Account = key
|
||||
Account = key,
|
||||
AccessGroup = "TEAMID.bitwarden"
|
||||
};
|
||||
|
||||
if(data != null)
|
|
@ -7,7 +7,7 @@ using MonoTouch.Foundation;
|
|||
#endif
|
||||
using Plugin.Settings.Abstractions;
|
||||
|
||||
namespace Bit.iOS.Services
|
||||
namespace Bit.iOS.Core.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Main implementation for ISettings
|
|
@ -33,6 +33,14 @@
|
|||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<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>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Plugin.Settings.Abstractions, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Xam.Plugins.Settings.2.1.0\lib\Xamarin.iOS10\Plugin.Settings.Abstractions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="SQLite-net, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\sqlite-net-pcl.1.1.1\lib\portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10\SQLite-net.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
|
@ -48,10 +56,14 @@
|
|||
<ItemGroup>
|
||||
<Compile Include="Constants.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Services\KeyChainStorageService.cs" />
|
||||
<Compile Include="Services\Settings.cs" />
|
||||
<Compile Include="Services\SqlService.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<None Include="packages.config">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\App\App.csproj">
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
<packages>
|
||||
<package id="sqlite-net-pcl" version="1.1.1" targetFramework="xamarinios10" />
|
||||
<package id="SQLitePCL.raw" version="0.8.6" targetFramework="xamarinios10" />
|
||||
<package id="Xam.Plugins.Settings" version="2.1.0" targetFramework="xamarinios10" />
|
||||
</packages>
|
|
@ -2,20 +2,22 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Bit.App.Abstractions;
|
||||
using Bit.iOS.Core;
|
||||
using Bit.iOS.Extension.Models;
|
||||
using Foundation;
|
||||
using MobileCoreServices;
|
||||
using Newtonsoft.Json;
|
||||
using UIKit;
|
||||
using Microsoft.Practices.Unity;
|
||||
using XLabs.Ioc;
|
||||
|
||||
namespace Bit.iOS.Extension
|
||||
{
|
||||
public partial class ActionViewController : UIViewController
|
||||
{
|
||||
public ActionViewController(IntPtr handle) : base(handle)
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
public Context Context { get; set; }
|
||||
|
||||
|
@ -27,17 +29,20 @@ namespace Bit.iOS.Extension
|
|||
base.ViewWillAppear(animated);
|
||||
}
|
||||
|
||||
public override void ViewDidLoad()
|
||||
public async override void ViewDidLoad()
|
||||
{
|
||||
base.ViewDidLoad();
|
||||
|
||||
List<Tuple<string, string>> sites = new List<Tuple<string, string>>();
|
||||
for(int i = 1; i <= 100; i++)
|
||||
{
|
||||
sites.Add(new Tuple<string, string>("Site " + i, "Username " + i));
|
||||
}
|
||||
|
||||
tableView.Source = new TableSource(sites, this);
|
||||
Debug.WriteLine("BW LOG, Container");
|
||||
var siteService = Resolver.Resolve<ISiteService>();
|
||||
Debug.WriteLine("BW LOG, siteService: " + siteService);
|
||||
var sites = await siteService.GetAllAsync();
|
||||
Debug.WriteLine("BW LOG, sites: " + sites.Count());
|
||||
var siteModels = sites.Select(s => new SiteViewModel(s));
|
||||
Debug.WriteLine("BW LOG, siteModels: " + siteModels.Count());
|
||||
var filteredSiteModels = siteModels.Where(s => s.HostName == Context.Url?.Host);
|
||||
Debug.WriteLine("BW LOG, filteredSiteModels: " + filteredSiteModels.Count());
|
||||
tableView.Source = new TableSource(filteredSiteModels, this);
|
||||
AutomaticallyAdjustsScrollViewInsets = false;
|
||||
}
|
||||
|
||||
|
@ -59,11 +64,11 @@ namespace Bit.iOS.Extension
|
|||
{
|
||||
private const string CellIdentifier = "TableCell";
|
||||
|
||||
private IEnumerable<Tuple<string, string>> _tableItems;
|
||||
private IEnumerable<SiteViewModel> _tableItems;
|
||||
private Context _context;
|
||||
private ActionViewController _controller;
|
||||
|
||||
public TableSource(IEnumerable<Tuple<string, string>> items, ActionViewController controller)
|
||||
public TableSource(IEnumerable<SiteViewModel> items, ActionViewController controller)
|
||||
{
|
||||
_tableItems = items;
|
||||
_context = controller.Context;
|
||||
|
@ -86,8 +91,8 @@ namespace Bit.iOS.Extension
|
|||
cell = new UITableViewCell(UITableViewCellStyle.Subtitle, CellIdentifier);
|
||||
}
|
||||
|
||||
cell.TextLabel.Text = item.Item1;
|
||||
cell.DetailTextLabel.Text = item.Item2;
|
||||
cell.TextLabel.Text = item.Name;
|
||||
cell.DetailTextLabel.Text = item.Username;
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,5 +6,9 @@
|
|||
<array>
|
||||
<string>group.com.8bit.bitwarden</string>
|
||||
</array>
|
||||
<key>keychain-access-groups</key>
|
||||
<array>
|
||||
<string>TEAMID.bitwarden</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
@ -14,6 +14,7 @@ using Bit.iOS.Core;
|
|||
using Newtonsoft.Json;
|
||||
using Bit.iOS.Extension.Models;
|
||||
using MobileCoreServices;
|
||||
using Plugin.Settings.Abstractions;
|
||||
|
||||
namespace Bit.iOS.Extension
|
||||
{
|
||||
|
@ -87,7 +88,7 @@ namespace Bit.iOS.Extension
|
|||
// Services
|
||||
.RegisterType<IDatabaseService, DatabaseService>(new ContainerControlledLifetimeManager())
|
||||
.RegisterType<ISqlService, SqlService>(new ContainerControlledLifetimeManager())
|
||||
//.RegisterType<ISecureStorageService, KeyChainStorageService>(new ContainerControlledLifetimeManager())
|
||||
.RegisterType<ISecureStorageService, KeyChainStorageService>(new ContainerControlledLifetimeManager())
|
||||
.RegisterType<ICryptoService, CryptoService>(new ContainerControlledLifetimeManager())
|
||||
.RegisterType<IAuthService, AuthService>(new ContainerControlledLifetimeManager())
|
||||
.RegisterType<IFolderService, FolderService>(new ContainerControlledLifetimeManager())
|
||||
|
@ -101,11 +102,13 @@ namespace Bit.iOS.Extension
|
|||
.RegisterType<ISiteApiRepository, SiteApiRepository>(new ContainerControlledLifetimeManager())
|
||||
.RegisterType<IAuthApiRepository, AuthApiRepository>(new ContainerControlledLifetimeManager());
|
||||
// Other
|
||||
//.RegisterInstance(CrossSettings.Current, new ContainerControlledLifetimeManager())
|
||||
//.RegisterInstance(CrossConnectivity.Current, new ContainerControlledLifetimeManager())
|
||||
//.RegisterInstance(UserDialogs.Instance, new ContainerControlledLifetimeManager())
|
||||
//.RegisterInstance(CrossFingerprint.Current, new ContainerControlledLifetimeManager());
|
||||
|
||||
ISettings settings = new Settings("group.com.8bit.bitwarden");
|
||||
container.RegisterInstance(settings, new ContainerControlledLifetimeManager());
|
||||
|
||||
Resolver.SetResolver(new UnityResolver(container));
|
||||
}
|
||||
|
||||
|
|
44
src/iOS.Extension/Models/SiteViewModel.cs
Normal file
44
src/iOS.Extension/Models/SiteViewModel.cs
Normal file
|
@ -0,0 +1,44 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Bit.App.Models;
|
||||
|
||||
namespace Bit.iOS.Extension.Models
|
||||
{
|
||||
public class SiteViewModel
|
||||
{
|
||||
public SiteViewModel(Site site)
|
||||
{
|
||||
Id = site.Id;
|
||||
Name = site.Name?.Decrypt();
|
||||
Username = site.Username?.Decrypt();
|
||||
Password = site.Password?.Decrypt();
|
||||
Uri = site.Uri?.Decrypt();
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Password { get; set; }
|
||||
public string Uri { get; set; }
|
||||
public string HostName
|
||||
{
|
||||
get
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(Uri))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return new Uri(Uri)?.Host;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -111,6 +111,7 @@
|
|||
</Compile>
|
||||
<None Include="Info.plist" />
|
||||
<None Include="Entitlements.plist" />
|
||||
<Compile Include="Models\SiteViewModel.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<InterfaceDefinition Include="MainInterface.storyboard" />
|
||||
<None Include="packages.config">
|
||||
|
@ -118,6 +119,14 @@
|
|||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<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>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Plugin.Settings.Abstractions, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Xam.Plugins.Settings.2.1.0\lib\Xamarin.iOS10\Plugin.Settings.Abstractions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
<package id="sqlite-net-pcl" version="1.1.1" targetFramework="xamarinios10" />
|
||||
<package id="SQLitePCL.raw" version="0.8.6" targetFramework="xamarinios10" />
|
||||
<package id="Unity" version="3.5.1405-prerelease" targetFramework="xamarinios10" />
|
||||
<package id="Xam.Plugins.Settings" version="2.1.0" targetFramework="xamarinios10" />
|
||||
<package id="XLabs.IoC" version="2.0.5782" targetFramework="xamarinios10" />
|
||||
<package id="XLabs.IoC.Unity" version="2.0.5782" targetFramework="xamarinios10" />
|
||||
</packages>
|
|
@ -6,5 +6,9 @@
|
|||
<array>
|
||||
<string>group.com.8bit.bitwarden</string>
|
||||
</array>
|
||||
<key>keychain-access-groups</key>
|
||||
<array>
|
||||
<string>TEAMID.bitwarden</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
@ -110,10 +110,8 @@
|
|||
<Compile Include="Controls\ExtendedEntryRenderer.cs" />
|
||||
<Compile Include="Controls\ExtendedTabbedPageRenderer.cs" />
|
||||
<Compile Include="Services\ClipboardService.cs" />
|
||||
<Compile Include="Services\KeyChainStorageService.cs" />
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="AppDelegate.cs" />
|
||||
<Compile Include="Services\Settings.cs" />
|
||||
<None Include="Entitlements.plist" />
|
||||
<None Include="Info.plist" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
|
Loading…
Reference in a new issue