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

local attachment storage & docker image

This commit is contained in:
Kyle Spearrin
2017-08-08 17:27:01 -04:00
parent e50b6240e4
commit fecd5b3a1a
13 changed files with 260 additions and 7 deletions

View File

@ -268,5 +268,24 @@ namespace Bit.Core.Utilities
{
return JsonConvert.DeserializeObject<T>(JsonConvert.SerializeObject(obj));
}
public static bool FullFramework()
{
#if NET461
return true;
#else
return false;
#endif
}
public static bool SettingHasValue(string setting)
{
if(string.IsNullOrWhiteSpace(setting) || setting.Equals("SECRET"))
{
return false;
}
return true;
}
}
}

View File

@ -15,7 +15,9 @@ using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
#if NET461
using Microsoft.WindowsAzure.Storage;
#endif
using System;
using System.IO;
using SqlServerRepos = Bit.Core.Repositories.SqlServer;
@ -53,23 +55,38 @@ namespace Bit.Core.Utilities
{
services.AddSingleton<IMailService, RazorViewMailService>();
if(!string.IsNullOrWhiteSpace(globalSettings.Mail.SendGridApiKey))
if(CoreHelpers.SettingHasValue(globalSettings.Mail.SendGridApiKey))
{
services.AddSingleton<IMailDeliveryService, SendGridMailDeliveryService>();
}
else if(CoreHelpers.SettingHasValue(globalSettings.Mail?.Smtp?.Host) &&
CoreHelpers.SettingHasValue(globalSettings.Mail?.Smtp?.Username) &&
CoreHelpers.SettingHasValue(globalSettings.Mail?.Smtp?.Password))
{
services.AddSingleton<IMailDeliveryService, SmtpMailDeliveryService>();
}
else
{
services.AddSingleton<IMailDeliveryService, NoopMailDeliveryService>();
}
#if NET461
services.AddSingleton<IPushNotificationService, NotificationHubPushNotificationService>();
services.AddSingleton<IPushRegistrationService, NotificationHubPushRegistrationService>();
if(globalSettings.SelfHosted)
{
services.AddSingleton<IPushNotificationService, NoopPushNotificationService>();
services.AddSingleton<IPushRegistrationService, NoopPushRegistrationService>();
}
else
{
services.AddSingleton<IPushNotificationService, NotificationHubPushNotificationService>();
services.AddSingleton<IPushRegistrationService, NotificationHubPushRegistrationService>();
}
#else
services.AddSingleton<IPushNotificationService, NoopPushNotificationService>();
services.AddSingleton<IPushRegistrationService, NoopPushRegistrationService>();
#endif
if(!string.IsNullOrWhiteSpace(globalSettings.Storage.ConnectionString))
if(CoreHelpers.SettingHasValue(globalSettings.Storage.ConnectionString))
{
services.AddSingleton<IBlockIpService, AzureQueueBlockIpService>();
}
@ -78,10 +95,14 @@ namespace Bit.Core.Utilities
services.AddSingleton<IBlockIpService, NoopBlockIpService>();
}
if(!string.IsNullOrWhiteSpace(globalSettings.Attachment.ConnectionString))
if(CoreHelpers.SettingHasValue(globalSettings.Attachment.ConnectionString))
{
services.AddSingleton<IAttachmentStorageService, AzureAttachmentStorageService>();
}
else if(CoreHelpers.SettingHasValue(globalSettings.Attachment.BaseDirectory))
{
services.AddSingleton<IAttachmentStorageService, LocalAttachmentStorageService>();
}
else
{
services.AddSingleton<IAttachmentStorageService, NoopAttachmentStorageService>();
@ -169,8 +190,8 @@ namespace Bit.Core.Utilities
{
identityServerBuilder.AddTemporarySigningCredential();
}
else if(!string.IsNullOrWhiteSpace(globalSettings.IdentityServer.CertificatePassword) &&
System.IO.File.Exists("identity.pfx"))
else if(!string.IsNullOrWhiteSpace(globalSettings.IdentityServer.CertificatePassword)
&& File.Exists("identity.pfx"))
{
var identityServerCert = CoreHelpers.GetCertificate("identity.pfx",
globalSettings.IdentityServer.CertificatePassword);