1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-26 17:37:36 +01:00

convert more services to local resources

This commit is contained in:
Kyle Spearrin 2017-08-08 23:06:28 -04:00
parent e081213615
commit 7590ea37f9
9 changed files with 21 additions and 9 deletions

View File

@ -2,6 +2,7 @@
"globalSettings": {
"selfHosted": false,
"siteName": "bitwarden",
"projectName": "Api",
"stripeApiKey": "SECRET",
"baseServiceUri": {
"vault": "http://localhost:4001",

View File

@ -2,6 +2,7 @@
"globalSettings": {
"selfHosted": false,
"siteName": "bitwarden",
"projectName": "Billing",
"stripeApiKey": "SECRET",
"baseServiceUri": {
"vault": "http://localhost:4001",

View File

@ -51,6 +51,7 @@
<PackageReference Include="RazorLight" Version="1.1.0" />
<PackageReference Include="Sendgrid" Version="9.5.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="1.4.0" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="1.1.0" />
<PackageReference Include="Serilog.Sinks.AzureDocumentDB" Version="3.6.1" />
<PackageReference Include="Stripe.net" Version="7.8.0" />
<PackageReference Include="U2F.Core" Version="1.0.3" />

View File

@ -5,6 +5,8 @@
public bool SelfHosted { get; set; }
public virtual string SiteName { get; set; }
public virtual string StripeApiKey { get; set; }
public virtual string ProjectName { get; set; }
public virtual string LogDirectory { get; set; }
public virtual BaseServiceUriSettings BaseServiceUri { get; set; } = new BaseServiceUriSettings();
public virtual SqlServerSettings SqlServer { get; set; } = new SqlServerSettings();
public virtual MailSettings Mail { get; set; } = new MailSettings();
@ -68,6 +70,7 @@
public class DataProtectionSettings
{
public string CertificateThumbprint { get; set; }
public string Directory { get; set; }
}
public class DocumentDbSettings

View File

@ -280,7 +280,7 @@ namespace Bit.Core.Utilities
public static bool SettingHasValue(string setting)
{
if(string.IsNullOrWhiteSpace(setting) || setting.Equals("SECRET"))
if(string.IsNullOrWhiteSpace(setting) || setting.Equals("SECRET") || setting.Equals("REPLACE"))
{
return false;
}

View File

@ -26,15 +26,15 @@ namespace Bit.Core.Utilities
.Enrich.FromLogContext()
.Filter.ByIncludingOnly(filter);
if(globalSettings.DocumentDb != null && !string.IsNullOrWhiteSpace(globalSettings.DocumentDb.Uri) &&
!string.IsNullOrWhiteSpace(globalSettings.DocumentDb.Key))
if(globalSettings.DocumentDb != null && CoreHelpers.SettingHasValue(globalSettings.DocumentDb.Uri) &&
CoreHelpers.SettingHasValue(globalSettings.DocumentDb.Key))
{
config.WriteTo.AzureDocumentDB(new Uri(globalSettings.DocumentDb.Uri), globalSettings.DocumentDb.Key,
timeToLive: TimeSpan.FromDays(7));
}
else
else if(CoreHelpers.SettingHasValue(globalSettings.LogDirectory))
{
// local file sink
config.WriteTo.RollingFile($"{globalSettings.LogDirectory}/{globalSettings.ProjectName}/{{Date}}.txt");
}
var serilog = config.CreateLogger();

View File

@ -222,10 +222,10 @@ namespace Bit.Core.Utilities
return;
}
if(globalSettings.SelfHosted)
if(globalSettings.SelfHosted && CoreHelpers.SettingHasValue(globalSettings.DataProtection.Directory))
{
var dir = new DirectoryInfo("/etc/bitwarden/core/aspnet-dataprotection");
services.AddDataProtection().PersistKeysToFileSystem(dir);
services.AddDataProtection()
.PersistKeysToFileSystem(new DirectoryInfo(globalSettings.DataProtection.Directory));
}
#if NET461

View File

@ -2,6 +2,7 @@
"globalSettings": {
"selfHosted": false,
"siteName": "bitwarden",
"projectName": "Identity",
"stripeApiKey": "SECRET",
"baseServiceUri": {
"vault": "http://localhost:4001",

View File

@ -10,6 +10,7 @@ namespace Setup
{
private static string[] _args = null;
private static IDictionary<string, string> _parameters = null;
private static string _outputDir = null;
private static string _domain = null;
private static string _url = null;
private static string _identityCertPassword = null;
@ -22,6 +23,8 @@ namespace Setup
_args = args;
_parameters = ParseParameters();
_outputDir = _parameters.ContainsKey("out") ?
_parameters["out"].ToLowerInvariant() : "/etc/bitwarden";
_domain = _parameters.ContainsKey("domain") ?
_parameters["domain"].ToLowerInvariant() : "localhost";
_letsEncrypt = _parameters.ContainsKey("letsencrypt") ?
@ -253,8 +256,10 @@ globalSettings:baseServiceUri:api={_url}/api
globalSettings:baseServiceUri:identity={_url}/identity
globalSettings:sqlServer:connectionString={dbConnectionString}
globalSettings:identityServer:certificatePassword={_identityCertPassword}
globalSettings:attachment:baseDirectory=/etc/bitwarden/core/attachments
globalSettings:attachment:baseDirectory={_outputDir}/core/attachments
globalSettings:attachment:baseUrl={_url}/attachments
globalSettings:dataProtection:directory={_outputDir}/core/aspnet-dataprotection
globalSettings:logDirectory={_outputDir}/core/logs
globalSettings:duo:aKey={Helpers.SecureRandomString(32, alpha: true, numeric: true)}
globalSettings:yubico:clientId=REPLACE
globalSettings:yubico:REPLACE");