1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 15:42:48 -05:00

PersistKeysToFileSystem when selfhosted

This commit is contained in:
Kyle Spearrin
2017-08-08 00:02:52 -04:00
parent 3e7c0f7ca1
commit e7905dec04
8 changed files with 51 additions and 12 deletions

View File

@ -17,6 +17,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.WindowsAzure.Storage;
using System;
using System.IO;
using SqlServerRepos = Bit.Core.Repositories.SqlServer;
namespace Bit.Core.Utilities
@ -195,10 +196,19 @@ namespace Bit.Core.Utilities
public static void AddCustomDataProtectionServices(
this IServiceCollection services, IHostingEnvironment env, GlobalSettings globalSettings)
{
if(env.IsDevelopment())
{
return;
}
if(globalSettings.SelfHosted)
{
var dir = new DirectoryInfo("/etc/bitwarden/core/aspnet-dataprotection");
services.AddDataProtection().PersistKeysToFileSystem(dir);
}
#if NET461
if(!env.IsDevelopment() && !globalSettings.SelfHosted &&
!string.IsNullOrWhiteSpace(globalSettings.Storage.ConnectionString) &&
!string.IsNullOrWhiteSpace(globalSettings.DataProtection.CertificateThumbprint))
if(!globalSettings.SelfHosted)
{
var dataProtectionCert = CoreHelpers.GetCertificate(globalSettings.DataProtection.CertificateThumbprint);
var storageAccount = CloudStorageAccount.Parse(globalSettings.Storage.ConnectionString);