1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 23:52:50 -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

@ -1,3 +1,4 @@
*
!obj/Docker/publish/*
!obj/Docker/empty/
!entrypoint.sh

View File

@ -22,4 +22,7 @@ done
WORKDIR /app
EXPOSE 80
COPY obj/Docker/publish .
ENTRYPOINT ["dotnet", "Api.dll"]
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

3
src/Api/entrypoint.sh Normal file
View File

@ -0,0 +1,3 @@
#!/bin/sh
dotnet /app/Api.dll

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);