Browse Source

change name to key connector

pull/3/head
Kyle Spearrin 4 years ago
parent
commit
e8a4cd862c
  1. 2
      bitwarden-key-connector.sln
  2. 0
      src/KeyConnector/.dockerignore
  3. 2
      src/KeyConnector/Controllers/MiscController.cs
  4. 10
      src/KeyConnector/Controllers/UserKeysController.cs
  5. 0
      src/KeyConnector/Dockerfile
  6. 4
      src/KeyConnector/HostedServices/DatabaseMigrationHostedService.cs
  7. 4
      src/KeyConnector/KeyConnector.csproj
  8. 4
      src/KeyConnector/KeyConnectorSettings.cs
  9. 8
      src/KeyConnector/Migrations/MySql/20210820155954_InitialCreate.Designer.cs
  10. 2
      src/KeyConnector/Migrations/MySql/20210820155954_InitialCreate.cs
  11. 8
      src/KeyConnector/Migrations/MySql/MySqlDatabaseContextModelSnapshot.cs
  12. 8
      src/KeyConnector/Migrations/PostgreSql/20210820160016_InitialCreate.Designer.cs
  13. 2
      src/KeyConnector/Migrations/PostgreSql/20210820160016_InitialCreate.cs
  14. 8
      src/KeyConnector/Migrations/PostgreSql/PostgreSqlDatabaseContextModelSnapshot.cs
  15. 8
      src/KeyConnector/Migrations/SqlServer/20210820154908_InitialCreate.Designer.cs
  16. 2
      src/KeyConnector/Migrations/SqlServer/20210820154908_InitialCreate.cs
  17. 8
      src/KeyConnector/Migrations/SqlServer/SqlServerDatabaseContextModelSnapshot.cs
  18. 8
      src/KeyConnector/Migrations/Sqlite/20210820155938_InitialCreate.Designer.cs
  19. 2
      src/KeyConnector/Migrations/Sqlite/20210820155938_InitialCreate.cs
  20. 8
      src/KeyConnector/Migrations/Sqlite/SqliteDatabaseContextModelSnapshot.cs
  21. 2
      src/KeyConnector/Models/IStoredItem.cs
  22. 2
      src/KeyConnector/Models/UserKeyModel.cs
  23. 2
      src/KeyConnector/Models/UserKeyRequestModel.cs
  24. 2
      src/KeyConnector/Models/UserKeyResponseModel.cs
  25. 2
      src/KeyConnector/Program.cs
  26. 0
      src/KeyConnector/Properties/launchSettings.json
  27. 2
      src/KeyConnector/Repositories/EntityFramework/ApplicationDataRepository.cs
  28. 2
      src/KeyConnector/Repositories/EntityFramework/BaseRepository.cs
  29. 20
      src/KeyConnector/Repositories/EntityFramework/DatabaseContext.cs
  30. 6
      src/KeyConnector/Repositories/EntityFramework/DatabaseContextFactory.cs
  31. 4
      src/KeyConnector/Repositories/EntityFramework/UserKeyRepository.cs
  32. 2
      src/KeyConnector/Repositories/IApplicationDataRepository.cs
  33. 2
      src/KeyConnector/Repositories/IRepository.cs
  34. 4
      src/KeyConnector/Repositories/IUserKeyRepository.cs
  35. 2
      src/KeyConnector/Repositories/JsonFile/ApplicationDataRepository.cs
  36. 4
      src/KeyConnector/Repositories/JsonFile/Repository.cs
  37. 4
      src/KeyConnector/Repositories/JsonFile/UserKeyRepository.cs
  38. 4
      src/KeyConnector/Repositories/Mongo/ApplicationDataRepository.cs
  39. 4
      src/KeyConnector/Repositories/Mongo/BaseRepository.cs
  40. 6
      src/KeyConnector/Repositories/Mongo/UserKeyRepository.cs
  41. 6
      src/KeyConnector/Services/AwsKmsRsaKeyService.cs
  42. 6
      src/KeyConnector/Services/AzureKeyVaultCertificateProviderService.cs
  43. 6
      src/KeyConnector/Services/AzureKeyVaultRsaKeyService.cs
  44. 6
      src/KeyConnector/Services/AzureStorageCertificateProviderService.cs
  45. 2
      src/KeyConnector/Services/CryptoFunctionService.cs
  46. 4
      src/KeyConnector/Services/CryptoService.cs
  47. 6
      src/KeyConnector/Services/FilesystemCertificateProviderService.cs
  48. 4
      src/KeyConnector/Services/GoogleCloudKmsRsaKeyService.cs
  49. 6
      src/KeyConnector/Services/HashicorpVaultCertificateProviderService.cs
  50. 2
      src/KeyConnector/Services/ICertificateProviderService.cs
  51. 2
      src/KeyConnector/Services/ICryptoFunctionService.cs
  52. 2
      src/KeyConnector/Services/ICryptoService.cs
  53. 2
      src/KeyConnector/Services/IRsaKeyService.cs
  54. 2
      src/KeyConnector/Services/LocalCertificateRsaKeyService.cs
  55. 6
      src/KeyConnector/Services/Pkcs11RsaKeyService.cs
  56. 6
      src/KeyConnector/Services/StoreCertificateProviderService.cs
  57. 18
      src/KeyConnector/Startup.cs
  58. 2
      src/KeyConnector/appsettings.Development.json
  59. 2
      src/KeyConnector/appsettings.json
  60. 8
      src/KeyConnector/build.sh
  61. 2
      src/KeyConnector/entrypoint.sh

2
bitwarden-crypto-agent.sln → bitwarden-key-connector.sln

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31205.134
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CryptoAgent", "src\CryptoAgent\CryptoAgent.csproj", "{CAD440BF-93C9-4DEC-B083-99FD49B50429}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KeyConnector", "src\KeyConnector\KeyConnector.csproj", "{CAD440BF-93C9-4DEC-B083-99FD49B50429}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

0
src/CryptoAgent/.dockerignore → src/KeyConnector/.dockerignore

2
src/CryptoAgent/Controllers/MiscController.cs → src/KeyConnector/Controllers/MiscController.cs

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
using Microsoft.AspNetCore.Mvc;
using System;
namespace Bit.CryptoAgent.Controllers
namespace Bit.KeyConnector.Controllers
{
public class MiscController : Controller
{

10
src/CryptoAgent/Controllers/UserKeysController.cs → src/KeyConnector/Controllers/UserKeysController.cs

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
using Bit.CryptoAgent.Models;
using Bit.CryptoAgent.Repositories;
using Bit.CryptoAgent.Services;
using Bit.KeyConnector.Models;
using Bit.KeyConnector.Repositories;
using Bit.KeyConnector.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
@ -10,7 +10,7 @@ using System; @@ -10,7 +10,7 @@ using System;
using System.Security.Claims;
using System.Threading.Tasks;
namespace Bit.CryptoAgent.Controllers
namespace Bit.KeyConnector.Controllers
{
[Authorize("Application")]
[Route("user-keys")]
@ -47,7 +47,7 @@ namespace Bit.CryptoAgent.Controllers @@ -47,7 +47,7 @@ namespace Bit.CryptoAgent.Controllers
var response = new UserKeyResponseModel
{
Key = await _cryptoService.AesDecryptToB64Async(user.Key)
};
};
return new JsonResult(response);
}

0
src/CryptoAgent/Dockerfile → src/KeyConnector/Dockerfile

4
src/CryptoAgent/HostedServices/DatabaseMigrationHostedService.cs → src/KeyConnector/HostedServices/DatabaseMigrationHostedService.cs

@ -1,13 +1,13 @@ @@ -1,13 +1,13 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Bit.CryptoAgent.Repositories.EntityFramework;
using Bit.KeyConnector.Repositories.EntityFramework;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace Bit.CryptoAgent.HostedServices
namespace Bit.KeyConnector.HostedServices
{
public class DatabaseMigrationHostedService : IHostedService, IDisposable
{

4
src/CryptoAgent/CryptoAgent.csproj → src/KeyConnector/KeyConnector.csproj

@ -2,8 +2,8 @@ @@ -2,8 +2,8 @@
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>Bit.CryptoAgent</RootNamespace>
<UserSecretsId>bitwarden-CryptoAgent</UserSecretsId>
<RootNamespace>Bit.KeyConnector</RootNamespace>
<UserSecretsId>bitwarden-KeyConnector</UserSecretsId>
<GenerateRuntimeConfigurationFiles>True</GenerateRuntimeConfigurationFiles>
</PropertyGroup>

4
src/CryptoAgent/CryptoAgentSettings.cs → src/KeyConnector/KeyConnectorSettings.cs

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
namespace Bit.CryptoAgent
namespace Bit.KeyConnector
{
public class CryptoAgentSettings
public class KeyConnectorSettings
{
public string WebVaultUri { get; set; }
public string IdentityServerUri { get; set; }

8
src/CryptoAgent/Migrations/MySql/20210820155954_InitialCreate.Designer.cs → src/KeyConnector/Migrations/MySql/20210820155954_InitialCreate.Designer.cs generated

@ -1,12 +1,12 @@ @@ -1,12 +1,12 @@
// <auto-generated />
using System;
using Bit.CryptoAgent.Repositories.EntityFramework;
using Bit.KeyConnector.Repositories.EntityFramework;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Bit.CryptoAgent.Migrations.MySql
namespace Bit.KeyConnector.Migrations.MySql
{
[DbContext(typeof(MySqlDatabaseContext))]
[Migration("20210820155954_InitialCreate")]
@ -19,7 +19,7 @@ namespace Bit.CryptoAgent.Migrations.MySql @@ -19,7 +19,7 @@ namespace Bit.CryptoAgent.Migrations.MySql
.HasAnnotation("Relational:MaxIdentifierLength", 64)
.HasAnnotation("ProductVersion", "5.0.9");
modelBuilder.Entity("Bit.CryptoAgent.Repositories.EntityFramework.ApplicationData", b =>
modelBuilder.Entity("Bit.KeyConnector.Repositories.EntityFramework.ApplicationData", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -33,7 +33,7 @@ namespace Bit.CryptoAgent.Migrations.MySql @@ -33,7 +33,7 @@ namespace Bit.CryptoAgent.Migrations.MySql
b.ToTable("ApplicationDatas");
});
modelBuilder.Entity("Bit.CryptoAgent.Repositories.EntityFramework.UserKey", b =>
modelBuilder.Entity("Bit.KeyConnector.Repositories.EntityFramework.UserKey", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()

2
src/CryptoAgent/Migrations/MySql/20210820155954_InitialCreate.cs → src/KeyConnector/Migrations/MySql/20210820155954_InitialCreate.cs

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Bit.CryptoAgent.Migrations.MySql
namespace Bit.KeyConnector.Migrations.MySql
{
public partial class InitialCreate : Migration
{

8
src/CryptoAgent/Migrations/MySql/MySqlDatabaseContextModelSnapshot.cs → src/KeyConnector/Migrations/MySql/MySqlDatabaseContextModelSnapshot.cs

@ -1,11 +1,11 @@ @@ -1,11 +1,11 @@
// <auto-generated />
using System;
using Bit.CryptoAgent.Repositories.EntityFramework;
using Bit.KeyConnector.Repositories.EntityFramework;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Bit.CryptoAgent.Migrations.MySql
namespace Bit.KeyConnector.Migrations.MySql
{
[DbContext(typeof(MySqlDatabaseContext))]
partial class MySqlDatabaseContextModelSnapshot : ModelSnapshot
@ -17,7 +17,7 @@ namespace Bit.CryptoAgent.Migrations.MySql @@ -17,7 +17,7 @@ namespace Bit.CryptoAgent.Migrations.MySql
.HasAnnotation("Relational:MaxIdentifierLength", 64)
.HasAnnotation("ProductVersion", "5.0.9");
modelBuilder.Entity("Bit.CryptoAgent.Repositories.EntityFramework.ApplicationData", b =>
modelBuilder.Entity("Bit.KeyConnector.Repositories.EntityFramework.ApplicationData", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -31,7 +31,7 @@ namespace Bit.CryptoAgent.Migrations.MySql @@ -31,7 +31,7 @@ namespace Bit.CryptoAgent.Migrations.MySql
b.ToTable("ApplicationDatas");
});
modelBuilder.Entity("Bit.CryptoAgent.Repositories.EntityFramework.UserKey", b =>
modelBuilder.Entity("Bit.KeyConnector.Repositories.EntityFramework.UserKey", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()

8
src/CryptoAgent/Migrations/PostgreSql/20210820160016_InitialCreate.Designer.cs → src/KeyConnector/Migrations/PostgreSql/20210820160016_InitialCreate.Designer.cs generated

@ -1,13 +1,13 @@ @@ -1,13 +1,13 @@
// <auto-generated />
using System;
using Bit.CryptoAgent.Repositories.EntityFramework;
using Bit.KeyConnector.Repositories.EntityFramework;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace Bit.CryptoAgent.Migrations.PostgreSql
namespace Bit.KeyConnector.Migrations.PostgreSql
{
[DbContext(typeof(PostgreSqlDatabaseContext))]
[Migration("20210820160016_InitialCreate")]
@ -21,7 +21,7 @@ namespace Bit.CryptoAgent.Migrations.PostgreSql @@ -21,7 +21,7 @@ namespace Bit.CryptoAgent.Migrations.PostgreSql
.HasAnnotation("ProductVersion", "5.0.9")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
modelBuilder.Entity("Bit.CryptoAgent.Repositories.EntityFramework.ApplicationData", b =>
modelBuilder.Entity("Bit.KeyConnector.Repositories.EntityFramework.ApplicationData", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -36,7 +36,7 @@ namespace Bit.CryptoAgent.Migrations.PostgreSql @@ -36,7 +36,7 @@ namespace Bit.CryptoAgent.Migrations.PostgreSql
b.ToTable("ApplicationDatas");
});
modelBuilder.Entity("Bit.CryptoAgent.Repositories.EntityFramework.UserKey", b =>
modelBuilder.Entity("Bit.KeyConnector.Repositories.EntityFramework.UserKey", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()

2
src/CryptoAgent/Migrations/PostgreSql/20210820160016_InitialCreate.cs → src/KeyConnector/Migrations/PostgreSql/20210820160016_InitialCreate.cs

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace Bit.CryptoAgent.Migrations.PostgreSql
namespace Bit.KeyConnector.Migrations.PostgreSql
{
public partial class InitialCreate : Migration
{

8
src/CryptoAgent/Migrations/PostgreSql/PostgreSqlDatabaseContextModelSnapshot.cs → src/KeyConnector/Migrations/PostgreSql/PostgreSqlDatabaseContextModelSnapshot.cs

@ -1,12 +1,12 @@ @@ -1,12 +1,12 @@
// <auto-generated />
using System;
using Bit.CryptoAgent.Repositories.EntityFramework;
using Bit.KeyConnector.Repositories.EntityFramework;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace Bit.CryptoAgent.Migrations.PostgreSql
namespace Bit.KeyConnector.Migrations.PostgreSql
{
[DbContext(typeof(PostgreSqlDatabaseContext))]
partial class PostgreSqlDatabaseContextModelSnapshot : ModelSnapshot
@ -19,7 +19,7 @@ namespace Bit.CryptoAgent.Migrations.PostgreSql @@ -19,7 +19,7 @@ namespace Bit.CryptoAgent.Migrations.PostgreSql
.HasAnnotation("ProductVersion", "5.0.9")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
modelBuilder.Entity("Bit.CryptoAgent.Repositories.EntityFramework.ApplicationData", b =>
modelBuilder.Entity("Bit.KeyConnector.Repositories.EntityFramework.ApplicationData", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -34,7 +34,7 @@ namespace Bit.CryptoAgent.Migrations.PostgreSql @@ -34,7 +34,7 @@ namespace Bit.CryptoAgent.Migrations.PostgreSql
b.ToTable("ApplicationDatas");
});
modelBuilder.Entity("Bit.CryptoAgent.Repositories.EntityFramework.UserKey", b =>
modelBuilder.Entity("Bit.KeyConnector.Repositories.EntityFramework.UserKey", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()

8
src/CryptoAgent/Migrations/SqlServer/20210820154908_InitialCreate.Designer.cs → src/KeyConnector/Migrations/SqlServer/20210820154908_InitialCreate.Designer.cs generated

@ -1,13 +1,13 @@ @@ -1,13 +1,13 @@
// <auto-generated />
using System;
using Bit.CryptoAgent.Repositories.EntityFramework;
using Bit.KeyConnector.Repositories.EntityFramework;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Bit.CryptoAgent.Migrations.SqlServer
namespace Bit.KeyConnector.Migrations.SqlServer
{
[DbContext(typeof(SqlServerDatabaseContext))]
[Migration("20210820154908_InitialCreate")]
@ -21,7 +21,7 @@ namespace Bit.CryptoAgent.Migrations.SqlServer @@ -21,7 +21,7 @@ namespace Bit.CryptoAgent.Migrations.SqlServer
.HasAnnotation("ProductVersion", "5.0.9")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Bit.CryptoAgent.Repositories.EntityFramework.ApplicationData", b =>
modelBuilder.Entity("Bit.KeyConnector.Repositories.EntityFramework.ApplicationData", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -36,7 +36,7 @@ namespace Bit.CryptoAgent.Migrations.SqlServer @@ -36,7 +36,7 @@ namespace Bit.CryptoAgent.Migrations.SqlServer
b.ToTable("ApplicationDatas");
});
modelBuilder.Entity("Bit.CryptoAgent.Repositories.EntityFramework.UserKey", b =>
modelBuilder.Entity("Bit.KeyConnector.Repositories.EntityFramework.UserKey", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()

2
src/CryptoAgent/Migrations/SqlServer/20210820154908_InitialCreate.cs → src/KeyConnector/Migrations/SqlServer/20210820154908_InitialCreate.cs

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Bit.CryptoAgent.Migrations.SqlServer
namespace Bit.KeyConnector.Migrations.SqlServer
{
public partial class InitialCreate : Migration
{

8
src/CryptoAgent/Migrations/SqlServer/SqlServerDatabaseContextModelSnapshot.cs → src/KeyConnector/Migrations/SqlServer/SqlServerDatabaseContextModelSnapshot.cs

@ -1,12 +1,12 @@ @@ -1,12 +1,12 @@
// <auto-generated />
using System;
using Bit.CryptoAgent.Repositories.EntityFramework;
using Bit.KeyConnector.Repositories.EntityFramework;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Bit.CryptoAgent.Migrations.SqlServer
namespace Bit.KeyConnector.Migrations.SqlServer
{
[DbContext(typeof(SqlServerDatabaseContext))]
partial class SqlServerDatabaseContextModelSnapshot : ModelSnapshot
@ -19,7 +19,7 @@ namespace Bit.CryptoAgent.Migrations.SqlServer @@ -19,7 +19,7 @@ namespace Bit.CryptoAgent.Migrations.SqlServer
.HasAnnotation("ProductVersion", "5.0.9")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Bit.CryptoAgent.Repositories.EntityFramework.ApplicationData", b =>
modelBuilder.Entity("Bit.KeyConnector.Repositories.EntityFramework.ApplicationData", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -34,7 +34,7 @@ namespace Bit.CryptoAgent.Migrations.SqlServer @@ -34,7 +34,7 @@ namespace Bit.CryptoAgent.Migrations.SqlServer
b.ToTable("ApplicationDatas");
});
modelBuilder.Entity("Bit.CryptoAgent.Repositories.EntityFramework.UserKey", b =>
modelBuilder.Entity("Bit.KeyConnector.Repositories.EntityFramework.UserKey", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()

8
src/CryptoAgent/Migrations/Sqlite/20210820155938_InitialCreate.Designer.cs → src/KeyConnector/Migrations/Sqlite/20210820155938_InitialCreate.Designer.cs generated

@ -1,12 +1,12 @@ @@ -1,12 +1,12 @@
// <auto-generated />
using System;
using Bit.CryptoAgent.Repositories.EntityFramework;
using Bit.KeyConnector.Repositories.EntityFramework;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Bit.CryptoAgent.Migrations.Sqlite
namespace Bit.KeyConnector.Migrations.Sqlite
{
[DbContext(typeof(SqliteDatabaseContext))]
[Migration("20210820155938_InitialCreate")]
@ -18,7 +18,7 @@ namespace Bit.CryptoAgent.Migrations.Sqlite @@ -18,7 +18,7 @@ namespace Bit.CryptoAgent.Migrations.Sqlite
modelBuilder
.HasAnnotation("ProductVersion", "5.0.9");
modelBuilder.Entity("Bit.CryptoAgent.Repositories.EntityFramework.ApplicationData", b =>
modelBuilder.Entity("Bit.KeyConnector.Repositories.EntityFramework.ApplicationData", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -32,7 +32,7 @@ namespace Bit.CryptoAgent.Migrations.Sqlite @@ -32,7 +32,7 @@ namespace Bit.CryptoAgent.Migrations.Sqlite
b.ToTable("ApplicationDatas");
});
modelBuilder.Entity("Bit.CryptoAgent.Repositories.EntityFramework.UserKey", b =>
modelBuilder.Entity("Bit.KeyConnector.Repositories.EntityFramework.UserKey", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()

2
src/CryptoAgent/Migrations/Sqlite/20210820155938_InitialCreate.cs → src/KeyConnector/Migrations/Sqlite/20210820155938_InitialCreate.cs

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Bit.CryptoAgent.Migrations.Sqlite
namespace Bit.KeyConnector.Migrations.Sqlite
{
public partial class InitialCreate : Migration
{

8
src/CryptoAgent/Migrations/Sqlite/SqliteDatabaseContextModelSnapshot.cs → src/KeyConnector/Migrations/Sqlite/SqliteDatabaseContextModelSnapshot.cs

@ -1,11 +1,11 @@ @@ -1,11 +1,11 @@
// <auto-generated />
using System;
using Bit.CryptoAgent.Repositories.EntityFramework;
using Bit.KeyConnector.Repositories.EntityFramework;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Bit.CryptoAgent.Migrations.Sqlite
namespace Bit.KeyConnector.Migrations.Sqlite
{
[DbContext(typeof(SqliteDatabaseContext))]
partial class SqliteDatabaseContextModelSnapshot : ModelSnapshot
@ -16,7 +16,7 @@ namespace Bit.CryptoAgent.Migrations.Sqlite @@ -16,7 +16,7 @@ namespace Bit.CryptoAgent.Migrations.Sqlite
modelBuilder
.HasAnnotation("ProductVersion", "5.0.9");
modelBuilder.Entity("Bit.CryptoAgent.Repositories.EntityFramework.ApplicationData", b =>
modelBuilder.Entity("Bit.KeyConnector.Repositories.EntityFramework.ApplicationData", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
@ -30,7 +30,7 @@ namespace Bit.CryptoAgent.Migrations.Sqlite @@ -30,7 +30,7 @@ namespace Bit.CryptoAgent.Migrations.Sqlite
b.ToTable("ApplicationDatas");
});
modelBuilder.Entity("Bit.CryptoAgent.Repositories.EntityFramework.UserKey", b =>
modelBuilder.Entity("Bit.KeyConnector.Repositories.EntityFramework.UserKey", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()

2
src/CryptoAgent/Models/IStoredItem.cs → src/KeyConnector/Models/IStoredItem.cs

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
using System;
namespace Bit.CryptoAgent.Models
namespace Bit.KeyConnector.Models
{
public interface IStoredItem<TId> where TId : IEquatable<TId>
{

2
src/CryptoAgent/Models/UserKeyModel.cs → src/KeyConnector/Models/UserKeyModel.cs

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
using System;
namespace Bit.CryptoAgent.Models
namespace Bit.KeyConnector.Models
{
public class UserKeyModel : BaseUserKeyModel, IStoredItem<Guid>
{

2
src/CryptoAgent/Models/UserKeyRequestModel.cs → src/KeyConnector/Models/UserKeyRequestModel.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
namespace Bit.CryptoAgent.Models
namespace Bit.KeyConnector.Models
{
public class UserKeyRequestModel
{

2
src/CryptoAgent/Models/UserKeyResponseModel.cs → src/KeyConnector/Models/UserKeyResponseModel.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
namespace Bit.CryptoAgent.Models
namespace Bit.KeyConnector.Models
{
public class UserKeyResponseModel
{

2
src/CryptoAgent/Program.cs → src/KeyConnector/Program.cs

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
using Microsoft.Extensions.Hosting;
using Serilog;
namespace Bit.CryptoAgent
namespace Bit.KeyConnector
{
public class Program
{

0
src/CryptoAgent/Properties/launchSettings.json → src/KeyConnector/Properties/launchSettings.json

2
src/CryptoAgent/Repositories/EntityFramework/ApplicationDataRepository.cs → src/KeyConnector/Repositories/EntityFramework/ApplicationDataRepository.cs

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
namespace Bit.CryptoAgent.Repositories.EntityFramework
namespace Bit.KeyConnector.Repositories.EntityFramework
{
public class ApplicationDataRepository : BaseRepository, IApplicationDataRepository
{

2
src/CryptoAgent/Repositories/EntityFramework/BaseRepository.cs → src/KeyConnector/Repositories/EntityFramework/BaseRepository.cs

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
using System;
using Microsoft.Extensions.DependencyInjection;
namespace Bit.CryptoAgent.Repositories.EntityFramework
namespace Bit.KeyConnector.Repositories.EntityFramework
{
public abstract class BaseRepository
{

20
src/CryptoAgent/Repositories/EntityFramework/DatabaseContext.cs → src/KeyConnector/Repositories/EntityFramework/DatabaseContext.cs

@ -1,8 +1,8 @@ @@ -1,8 +1,8 @@
using System.Linq;
using Bit.CryptoAgent.Models;
using Bit.KeyConnector.Models;
using Microsoft.EntityFrameworkCore;
namespace Bit.CryptoAgent.Repositories.EntityFramework
namespace Bit.KeyConnector.Repositories.EntityFramework
{
public abstract class DatabaseContext : DbContext
{
@ -12,9 +12,9 @@ namespace Bit.CryptoAgent.Repositories.EntityFramework @@ -12,9 +12,9 @@ namespace Bit.CryptoAgent.Repositories.EntityFramework
public class SqlServerDatabaseContext : DatabaseContext
{
private readonly CryptoAgentSettings _settings;
private readonly KeyConnectorSettings _settings;
public SqlServerDatabaseContext(CryptoAgentSettings settings)
public SqlServerDatabaseContext(KeyConnectorSettings settings)
{
_settings = settings;
}
@ -25,9 +25,9 @@ namespace Bit.CryptoAgent.Repositories.EntityFramework @@ -25,9 +25,9 @@ namespace Bit.CryptoAgent.Repositories.EntityFramework
public class PostgreSqlDatabaseContext : DatabaseContext
{
private readonly CryptoAgentSettings _settings;
private readonly KeyConnectorSettings _settings;
public PostgreSqlDatabaseContext(CryptoAgentSettings settings)
public PostgreSqlDatabaseContext(KeyConnectorSettings settings)
{
_settings = settings;
}
@ -38,9 +38,9 @@ namespace Bit.CryptoAgent.Repositories.EntityFramework @@ -38,9 +38,9 @@ namespace Bit.CryptoAgent.Repositories.EntityFramework
public class SqliteDatabaseContext : DatabaseContext
{
private readonly CryptoAgentSettings _settings;
private readonly KeyConnectorSettings _settings;
public SqliteDatabaseContext(CryptoAgentSettings settings)
public SqliteDatabaseContext(KeyConnectorSettings settings)
{
_settings = settings;
}
@ -51,9 +51,9 @@ namespace Bit.CryptoAgent.Repositories.EntityFramework @@ -51,9 +51,9 @@ namespace Bit.CryptoAgent.Repositories.EntityFramework
public class MySqlDatabaseContext : DatabaseContext
{
private readonly CryptoAgentSettings _settings;
private readonly KeyConnectorSettings _settings;
public MySqlDatabaseContext(CryptoAgentSettings settings)
public MySqlDatabaseContext(KeyConnectorSettings settings)
{
_settings = settings;
}

6
src/CryptoAgent/Repositories/EntityFramework/DatabaseContextFactory.cs → src/KeyConnector/Repositories/EntityFramework/DatabaseContextFactory.cs

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
namespace Bit.CryptoAgent.Repositories.EntityFramework
namespace Bit.KeyConnector.Repositories.EntityFramework
{
public class SqlServerDatabaseContextFactory : IDesignTimeDbContextFactory<SqlServerDatabaseContext>
{
@ -37,13 +37,13 @@ namespace Bit.CryptoAgent.Repositories.EntityFramework @@ -37,13 +37,13 @@ namespace Bit.CryptoAgent.Repositories.EntityFramework
public static class SettingsFactory
{
public static CryptoAgentSettings Settings { get; } = new CryptoAgentSettings();
public static KeyConnectorSettings Settings { get; } = new KeyConnectorSettings();
static SettingsFactory()
{
var configBuilder = new ConfigurationBuilder().AddUserSecrets<Startup>();
var config = configBuilder.Build();
ConfigurationBinder.Bind(config.GetSection("CryptoAgentSettings"), Settings);
ConfigurationBinder.Bind(config.GetSection("KeyConnectorSettings"), Settings);
}
}
}

4
src/CryptoAgent/Repositories/EntityFramework/UserKeyRepository.cs → src/KeyConnector/Repositories/EntityFramework/UserKeyRepository.cs

@ -1,9 +1,9 @@ @@ -1,9 +1,9 @@
using Bit.CryptoAgent.Models;
using Bit.KeyConnector.Models;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Threading.Tasks;
namespace Bit.CryptoAgent.Repositories.EntityFramework
namespace Bit.KeyConnector.Repositories.EntityFramework
{
public class UserKeyRepository : BaseRepository, IUserKeyRepository
{

2
src/CryptoAgent/Repositories/IApplicationDataRepository.cs → src/KeyConnector/Repositories/IApplicationDataRepository.cs

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
using System.Threading.Tasks;
namespace Bit.CryptoAgent.Repositories
namespace Bit.KeyConnector.Repositories
{
public interface IApplicationDataRepository
{

2
src/CryptoAgent/Repositories/IRepository.cs → src/KeyConnector/Repositories/IRepository.cs

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
using System.Threading.Tasks;
namespace Bit.CryptoAgent.Repositories
namespace Bit.KeyConnector.Repositories
{
public interface IRepository<TItem, TId>
{

4
src/CryptoAgent/Repositories/IUserKeyRepository.cs → src/KeyConnector/Repositories/IUserKeyRepository.cs

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
using Bit.CryptoAgent.Models;
using Bit.KeyConnector.Models;
using System;
namespace Bit.CryptoAgent.Repositories
namespace Bit.KeyConnector.Repositories
{
public interface IUserKeyRepository : IRepository<UserKeyModel, Guid>
{

2
src/CryptoAgent/Repositories/JsonFile/ApplicationDataRepository.cs → src/KeyConnector/Repositories/JsonFile/ApplicationDataRepository.cs

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
using JsonFlatFileDataStore;
using System.Threading.Tasks;
namespace Bit.CryptoAgent.Repositories.JsonFile
namespace Bit.KeyConnector.Repositories.JsonFile
{
public class ApplicationDataRepository : IApplicationDataRepository
{

4
src/CryptoAgent/Repositories/JsonFile/Repository.cs → src/KeyConnector/Repositories/JsonFile/Repository.cs

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
using Bit.CryptoAgent.Models;
using Bit.KeyConnector.Models;
using JsonFlatFileDataStore;
using System;
using System.Linq;
using System.Threading.Tasks;
namespace Bit.CryptoAgent.Repositories.JsonFile
namespace Bit.KeyConnector.Repositories.JsonFile
{
public class Repository<TItem, TId> : IRepository<TItem, TId>
where TId : IEquatable<TId>

4
src/CryptoAgent/Repositories/JsonFile/UserKeyRepository.cs → src/KeyConnector/Repositories/JsonFile/UserKeyRepository.cs

@ -1,9 +1,9 @@ @@ -1,9 +1,9 @@
using Bit.CryptoAgent.Models;
using Bit.KeyConnector.Models;
using JsonFlatFileDataStore;
using System;
using System.Threading.Tasks;
namespace Bit.CryptoAgent.Repositories.JsonFile
namespace Bit.KeyConnector.Repositories.JsonFile
{
public class UserKeyRepository : Repository<UserKeyModel, Guid>, IUserKeyRepository
{

4
src/CryptoAgent/Repositories/Mongo/ApplicationDataRepository.cs → src/KeyConnector/Repositories/Mongo/ApplicationDataRepository.cs

@ -2,12 +2,12 @@ @@ -2,12 +2,12 @@
using MongoDB.Driver;
using System.Threading.Tasks;
namespace Bit.CryptoAgent.Repositories.Mongo
namespace Bit.KeyConnector.Repositories.Mongo
{
public class ApplicationDataRepository : BaseRepository<ApplicationDataRepository.ApplicationData>,
IApplicationDataRepository
{
public ApplicationDataRepository(CryptoAgentSettings settings)
public ApplicationDataRepository(KeyConnectorSettings settings)
: base(settings, "ApplicationData")
{ }

4
src/CryptoAgent/Repositories/Mongo/BaseRepository.cs → src/KeyConnector/Repositories/Mongo/BaseRepository.cs

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
using MongoDB.Driver;
namespace Bit.CryptoAgent.Repositories.Mongo
namespace Bit.KeyConnector.Repositories.Mongo
{
public abstract class BaseRepository<T>
{
public BaseRepository(CryptoAgentSettings settings, string collectionName)
public BaseRepository(KeyConnectorSettings settings, string collectionName)
{
Client = new MongoClient(settings.Database.MongoConnectionString);
Database = Client.GetDatabase(settings.Database.MongoDatabaseName);

6
src/CryptoAgent/Repositories/Mongo/UserKeyRepository.cs → src/KeyConnector/Repositories/Mongo/UserKeyRepository.cs

@ -1,13 +1,13 @@ @@ -1,13 +1,13 @@
using Bit.CryptoAgent.Models;
using Bit.KeyConnector.Models;
using MongoDB.Driver;
using System;
using System.Threading.Tasks;
namespace Bit.CryptoAgent.Repositories.Mongo
namespace Bit.KeyConnector.Repositories.Mongo
{
public class UserKeyRepository : BaseRepository<UserKeyModel>, IUserKeyRepository
{
public UserKeyRepository(CryptoAgentSettings settings)
public UserKeyRepository(KeyConnectorSettings settings)
: base(settings, "UserKey")
{ }

6
src/CryptoAgent/Services/AwsKmsRsaKeyService.cs → src/KeyConnector/Services/AwsKmsRsaKeyService.cs

@ -5,15 +5,15 @@ using System.IO; @@ -5,15 +5,15 @@ using System.IO;
using System.Security.Cryptography;
using System.Threading.Tasks;
namespace Bit.CryptoAgent.Services
namespace Bit.KeyConnector.Services
{
public class AwsKmsRsaKeyService : IRsaKeyService
{
private readonly CryptoAgentSettings _settings;
private readonly KeyConnectorSettings _settings;
private readonly AmazonKeyManagementServiceClient _kmsClient;
public AwsKmsRsaKeyService(
CryptoAgentSettings settings)
KeyConnectorSettings settings)
{
_settings = settings;
_kmsClient = new AmazonKeyManagementServiceClient(settings.RsaKey.AwsAccessKeyId,

6
src/CryptoAgent/Services/AzureKeyVaultCertificateProviderService.cs → src/KeyConnector/Services/AzureKeyVaultCertificateProviderService.cs

@ -5,13 +5,13 @@ using System; @@ -5,13 +5,13 @@ using System;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
namespace Bit.CryptoAgent.Services
namespace Bit.KeyConnector.Services
{
public class AzureKeyVaultCertificateProviderService : ICertificateProviderService
{
private readonly CryptoAgentSettings _settings;
private readonly KeyConnectorSettings _settings;
public AzureKeyVaultCertificateProviderService(CryptoAgentSettings settings)
public AzureKeyVaultCertificateProviderService(KeyConnectorSettings settings)
{
_settings = settings;
}

6
src/CryptoAgent/Services/AzureKeyVaultRsaKeyService.cs → src/KeyConnector/Services/AzureKeyVaultRsaKeyService.cs

@ -4,18 +4,18 @@ using Azure.Security.KeyVault.Keys.Cryptography; @@ -4,18 +4,18 @@ using Azure.Security.KeyVault.Keys.Cryptography;
using System;
using System.Threading.Tasks;
namespace Bit.CryptoAgent.Services
namespace Bit.KeyConnector.Services
{
public class AzureKeyVaultRsaKeyService : IRsaKeyService
{
private readonly CryptoAgentSettings _settings;
private readonly KeyConnectorSettings _settings;
private readonly ClientSecretCredential _credential;
private KeyVaultKey _key;
private CryptographyClient _cryptographyClient;
public AzureKeyVaultRsaKeyService(
CryptoAgentSettings settings)
KeyConnectorSettings settings)
{
_settings = settings;
_credential = new ClientSecretCredential(_settings.RsaKey.AzureKeyvaultAdTenantId,

6
src/CryptoAgent/Services/AzureStorageCertificateProviderService.cs → src/KeyConnector/Services/AzureStorageCertificateProviderService.cs

@ -3,13 +3,13 @@ using System.IO; @@ -3,13 +3,13 @@ using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
namespace Bit.CryptoAgent.Services
namespace Bit.KeyConnector.Services
{
public class AzureStorageCertificateProviderService : ICertificateProviderService
{
private readonly CryptoAgentSettings _settings;
private readonly KeyConnectorSettings _settings;
public AzureStorageCertificateProviderService(CryptoAgentSettings settings)
public AzureStorageCertificateProviderService(KeyConnectorSettings settings)
{
_settings = settings;
}

2
src/CryptoAgent/Services/CryptoFunctionService.cs → src/KeyConnector/Services/CryptoFunctionService.cs

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
using System.Security.Cryptography;
using System.Threading.Tasks;
namespace Bit.CryptoAgent.Services
namespace Bit.KeyConnector.Services
{
public class CryptoFunctionService : ICryptoFunctionService
{

4
src/CryptoAgent/Services/CryptoService.cs → src/KeyConnector/Services/CryptoService.cs

@ -1,8 +1,8 @@ @@ -1,8 +1,8 @@
using Bit.CryptoAgent.Repositories;
using Bit.KeyConnector.Repositories;
using System;
using System.Threading.Tasks;
namespace Bit.CryptoAgent.Services
namespace Bit.KeyConnector.Services
{
public class CryptoService : ICryptoService
{

6
src/CryptoAgent/Services/FilesystemCertificateProviderService.cs → src/KeyConnector/Services/FilesystemCertificateProviderService.cs

@ -1,13 +1,13 @@ @@ -1,13 +1,13 @@
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
namespace Bit.CryptoAgent.Services
namespace Bit.KeyConnector.Services
{
public class FilesystemCertificateProviderService : ICertificateProviderService
{
private readonly CryptoAgentSettings _settings;
private readonly KeyConnectorSettings _settings;
public FilesystemCertificateProviderService(CryptoAgentSettings settings)
public FilesystemCertificateProviderService(KeyConnectorSettings settings)
{
_settings = settings;
}

4
src/CryptoAgent/Services/GoogleCloudKmsRsaKeyService.cs → src/KeyConnector/Services/GoogleCloudKmsRsaKeyService.cs

@ -4,7 +4,7 @@ using System; @@ -4,7 +4,7 @@ using System;
using System.Security.Cryptography;
using System.Threading.Tasks;
namespace Bit.CryptoAgent.Services
namespace Bit.KeyConnector.Services
{
public class GoogleCloudKmsRsaKeyService : IRsaKeyService
{
@ -13,7 +13,7 @@ namespace Bit.CryptoAgent.Services @@ -13,7 +13,7 @@ namespace Bit.CryptoAgent.Services
private readonly CryptoKeyVersionName _cryptoKeyVersionName;
public GoogleCloudKmsRsaKeyService(
CryptoAgentSettings settings)
KeyConnectorSettings settings)
{
_keyManagementServiceClient = KeyManagementServiceClient.Create();
_cryptoKeyName = new CryptoKeyName(settings.RsaKey.GoogleCloudProjectId,

6
src/CryptoAgent/Services/HashicorpVaultCertificateProviderService.cs → src/KeyConnector/Services/HashicorpVaultCertificateProviderService.cs

@ -4,13 +4,13 @@ using System.Threading.Tasks; @@ -4,13 +4,13 @@ using System.Threading.Tasks;
using VaultSharp;
using VaultSharp.V1.AuthMethods.Token;
namespace Bit.CryptoAgent.Services
namespace Bit.KeyConnector.Services
{
public class HashicorpVaultCertificateProviderService : ICertificateProviderService
{
private readonly CryptoAgentSettings _settings;
private readonly KeyConnectorSettings _settings;
public HashicorpVaultCertificateProviderService(CryptoAgentSettings settings)
public HashicorpVaultCertificateProviderService(KeyConnectorSettings settings)
{
_settings = settings;
}

2
src/CryptoAgent/Services/ICertificateProviderService.cs → src/KeyConnector/Services/ICertificateProviderService.cs

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
namespace Bit.CryptoAgent.Services
namespace Bit.KeyConnector.Services
{
public interface ICertificateProviderService
{

2
src/CryptoAgent/Services/ICryptoFunctionService.cs → src/KeyConnector/Services/ICryptoFunctionService.cs

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
using System.Security.Cryptography;
using System.Threading.Tasks;
namespace Bit.CryptoAgent.Services
namespace Bit.KeyConnector.Services
{
public interface ICryptoFunctionService
{

2
src/CryptoAgent/Services/ICryptoService.cs → src/KeyConnector/Services/ICryptoService.cs

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
using System.Threading.Tasks;
namespace Bit.CryptoAgent.Services
namespace Bit.KeyConnector.Services
{
public interface ICryptoService
{

2
src/CryptoAgent/Services/IRsaKeyService.cs → src/KeyConnector/Services/IRsaKeyService.cs

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
using System.Threading.Tasks;
namespace Bit.CryptoAgent.Services
namespace Bit.KeyConnector.Services
{
public interface IRsaKeyService
{

2
src/CryptoAgent/Services/LocalCertificateRsaKeyService.cs → src/KeyConnector/Services/LocalCertificateRsaKeyService.cs

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
namespace Bit.CryptoAgent.Services
namespace Bit.KeyConnector.Services
{
public class LocalCertificateRsaKeyService : IRsaKeyService
{

6
src/CryptoAgent/Services/Pkcs11RsaKeyService.cs → src/KeyConnector/Services/Pkcs11RsaKeyService.cs

@ -5,20 +5,20 @@ using System.Threading.Tasks; @@ -5,20 +5,20 @@ using System.Threading.Tasks;
using Net.Pkcs11Interop.Common;
using Net.Pkcs11Interop.HighLevelAPI;
namespace Bit.CryptoAgent.Services
namespace Bit.KeyConnector.Services
{
public class Pkcs11RsaKeyService : IRsaKeyService
{
private readonly ICertificateProviderService _certificateProviderService;
private readonly ICryptoFunctionService _cryptoFunctionService;
private readonly CryptoAgentSettings _settings;
private readonly KeyConnectorSettings _settings;
private X509Certificate2 _certificate;
public Pkcs11RsaKeyService(
ICertificateProviderService certificateProviderService,
ICryptoFunctionService cryptoFunctionService,
CryptoAgentSettings settings)
KeyConnectorSettings settings)
{
_certificateProviderService = certificateProviderService;
_cryptoFunctionService = cryptoFunctionService;

6
src/CryptoAgent/Services/StoreCertificateProviderService.cs → src/KeyConnector/Services/StoreCertificateProviderService.cs

@ -2,13 +2,13 @@ @@ -2,13 +2,13 @@
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace Bit.CryptoAgent.Services
namespace Bit.KeyConnector.Services
{
public class StoreCertificateProviderService : ICertificateProviderService
{
private readonly CryptoAgentSettings _settings;
private readonly KeyConnectorSettings _settings;
public StoreCertificateProviderService(CryptoAgentSettings settings)
public StoreCertificateProviderService(KeyConnectorSettings settings)
{
_settings = settings;
}

18
src/CryptoAgent/Startup.cs → src/KeyConnector/Startup.cs

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
using Bit.CryptoAgent.Repositories;
using Bit.CryptoAgent.Services;
using Bit.KeyConnector.Repositories;
using Bit.KeyConnector.Services;
using IdentityModel;
using IdentityServer4.AccessTokenValidation;
using JsonFlatFileDataStore;
@ -14,7 +14,7 @@ using System; @@ -14,7 +14,7 @@ using System;
using System.Globalization;
using System.Security.Claims;
namespace Bit.CryptoAgent
namespace Bit.KeyConnector
{
public class Startup
{
@ -34,8 +34,8 @@ namespace Bit.CryptoAgent @@ -34,8 +34,8 @@ namespace Bit.CryptoAgent
public void ConfigureServices(IServiceCollection services)
{
var settings = new CryptoAgentSettings();
ConfigurationBinder.Bind(Configuration.GetSection("CryptoAgentSettings"), settings);
var settings = new KeyConnectorSettings();
ConfigurationBinder.Bind(Configuration.GetSection("KeyConnectorSettings"), settings);
services.AddSingleton(s => settings);
AddAuthentication(services, settings);
@ -54,7 +54,7 @@ namespace Bit.CryptoAgent @@ -54,7 +54,7 @@ namespace Bit.CryptoAgent
}
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, CryptoAgentSettings settings)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, KeyConnectorSettings settings)
{
if (env.IsDevelopment())
{
@ -72,7 +72,7 @@ namespace Bit.CryptoAgent @@ -72,7 +72,7 @@ namespace Bit.CryptoAgent
app.UseEndpoints(endpoints => endpoints.MapDefaultControllerRoute());
}
private bool AddDatabase(IServiceCollection services, CryptoAgentSettings settings)
private bool AddDatabase(IServiceCollection services, KeyConnectorSettings settings)
{
var databaseProvider = settings.Database.Provider?.ToLowerInvariant();
var efDatabaseProvider = databaseProvider == "sqlserver" || databaseProvider == "postgresql" ||
@ -125,7 +125,7 @@ namespace Bit.CryptoAgent @@ -125,7 +125,7 @@ namespace Bit.CryptoAgent
return efDatabaseProvider;
}
private void AddRsaKeyProvider(IServiceCollection services, CryptoAgentSettings settings)
private void AddRsaKeyProvider(IServiceCollection services, KeyConnectorSettings settings)
{
var rsaKeyProvider = settings.RsaKey.Provider?.ToLowerInvariant();
if (rsaKeyProvider == "certificate" || rsaKeyProvider == "pkcs11")
@ -183,7 +183,7 @@ namespace Bit.CryptoAgent @@ -183,7 +183,7 @@ namespace Bit.CryptoAgent
}
}
private void AddAuthentication(IServiceCollection services, CryptoAgentSettings settings)
private void AddAuthentication(IServiceCollection services, KeyConnectorSettings settings)
{
services.Configure<IdentityOptions>(options =>
{

2
src/CryptoAgent/appsettings.Development.json → src/KeyConnector/appsettings.Development.json

@ -13,7 +13,7 @@ @@ -13,7 +13,7 @@
"FromLogContext"
]
},
"cryptoAgentSettings": {
"keyConnectorSettings": {
"webVaultUri": "https://localhost:8080/",
"identityServerUri": "http://localhost:33656/"
}

2
src/CryptoAgent/appsettings.json → src/KeyConnector/appsettings.json

@ -26,7 +26,7 @@ @@ -26,7 +26,7 @@
]
},
"AllowedHosts": "*",
"cryptoAgentSettings": {
"keyConnectorSettings": {
"webVaultUri": "https://vault.bitwarden.com/",
"identityServerUri": "https://identity.bitwarden.com/",
"database": {

8
src/CryptoAgent/build.sh → src/KeyConnector/build.sh

@ -8,12 +8,12 @@ echo -e "\n## Building Crypto Agent" @@ -8,12 +8,12 @@ echo -e "\n## Building Crypto Agent"
echo -e "\nBuilding app"
echo ".NET Core version $(dotnet --version)"
echo "Restore"
dotnet restore "$DIR/CryptoAgent.csproj"
dotnet restore "$DIR/KeyConnector.csproj"
echo "Clean"
dotnet clean "$DIR/CryptoAgent.csproj" -c "Release" -o "$DIR/obj/build-output/publish"
dotnet clean "$DIR/KeyConnector.csproj" -c "Release" -o "$DIR/obj/build-output/publish"
echo "Publish"
dotnet publish "$DIR/CryptoAgent.csproj" -c "Release" -o "$DIR/obj/build-output/publish"
dotnet publish "$DIR/KeyConnector.csproj" -c "Release" -o "$DIR/obj/build-output/publish"
echo -e "\nBuilding docker image"
docker --version
docker build -t bitwarden/crypto-agent "$DIR/."
docker build -t bitwarden/key-connector "$DIR/."

2
src/CryptoAgent/entrypoint.sh → src/KeyConnector/entrypoint.sh

@ -37,4 +37,4 @@ chown -R $USERNAME:$GROUPNAME /etc/bitwarden @@ -37,4 +37,4 @@ chown -R $USERNAME:$GROUPNAME /etc/bitwarden
cp /etc/bitwarden/ca-certificates/*.crt /usr/local/share/ca-certificates/ >/dev/null 2>&1 \
&& update-ca-certificates
exec gosu $USERNAME:$GROUPNAME dotnet /app/CryptoAgent.dll
exec gosu $USERNAME:$GROUPNAME dotnet /app/KeyConnector.dll
Loading…
Cancel
Save