diff --git a/bitwarden-server.sln b/bitwarden-server.sln
index 6dae86dc3f4f..75ed41577fef 100644
--- a/bitwarden-server.sln
+++ b/bitwarden-server.sln
@@ -76,11 +76,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PostgresMigrations", "util\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "test\Common\Common.csproj", "{17DA09D7-0212-4009-879E-6B9CFDE5FA60}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharedKernel", "src\SharedKernel\SharedKernel.csproj", "{55D65CC6-6F00-40DD-9EFC-9ED1F301A4F3}"
+EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infrastructure.Dapper", "src\Infrastructure.Dapper\Infrastructure.Dapper.csproj", "{AD933445-27CE-4D30-A6ED-9065309464AD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharedWeb", "src\SharedWeb\SharedWeb.csproj", "{713D44C0-1BC1-4024-96A3-A98A49F33908}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Infrastructure.EntityFramework", "src\Infrastructure.EntityFramework\Infrastructure.EntityFramework.csproj", "{ED880735-0250-43C7-9662-FDC7C7416E7F}"
+EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Billing.Test", "test\Billing.Test\Billing.Test.csproj", "{B8639B10-2157-44BC-8CE1-D9EB4B50971F}"
EndProject
Global
@@ -179,6 +182,10 @@ Global
{17DA09D7-0212-4009-879E-6B9CFDE5FA60}.Debug|Any CPU.Build.0 = Debug|Any CPU
{17DA09D7-0212-4009-879E-6B9CFDE5FA60}.Release|Any CPU.ActiveCfg = Release|Any CPU
{17DA09D7-0212-4009-879E-6B9CFDE5FA60}.Release|Any CPU.Build.0 = Release|Any CPU
+ {55D65CC6-6F00-40DD-9EFC-9ED1F301A4F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {55D65CC6-6F00-40DD-9EFC-9ED1F301A4F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {55D65CC6-6F00-40DD-9EFC-9ED1F301A4F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {55D65CC6-6F00-40DD-9EFC-9ED1F301A4F3}.Release|Any CPU.Build.0 = Release|Any CPU
{AD933445-27CE-4D30-A6ED-9065309464AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AD933445-27CE-4D30-A6ED-9065309464AD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AD933445-27CE-4D30-A6ED-9065309464AD}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -222,6 +229,7 @@ Global
{EDC0D688-D58C-4CE1-AA07-3606AC6874B8} = {4FDB6543-F68B-4202-9EA6-7FEA984D2D0A}
{0E99A21B-684B-4C59-9831-90F775CAB6F7} = {287CFF34-BBDB-4BC4-AF88-1E19A5A4679B}
{17DA09D7-0212-4009-879E-6B9CFDE5FA60} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84F}
+ {55D65CC6-6F00-40DD-9EFC-9ED1F301A4F3} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84D}
{AD933445-27CE-4D30-A6ED-9065309464AD} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84D}
{713D44C0-1BC1-4024-96A3-A98A49F33908} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84D}
{ED880735-0250-43C7-9662-FDC7C7416E7F} = {DD5BD056-4AAE-43EF-BBD2-0B569B8DA84D}
diff --git a/bitwarden_license/src/Sso/Controllers/InfoController.cs b/bitwarden_license/src/Sso/Controllers/InfoController.cs
index 7f3058ae95b0..063238a22d9c 100644
--- a/bitwarden_license/src/Sso/Controllers/InfoController.cs
+++ b/bitwarden_license/src/Sso/Controllers/InfoController.cs
@@ -1,5 +1,5 @@
using System;
-using Bit.Core.Utilities;
+using Bit.SharedKernel.Utilities;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Sso.Controllers
@@ -16,7 +16,7 @@ public DateTime GetAlive()
[HttpGet("~/version")]
public JsonResult GetVersion()
{
- return Json(CoreHelpers.GetVersion());
+ return Json(VersionHelper.GetVersion());
}
}
}
diff --git a/bitwarden_license/src/Sso/Startup.cs b/bitwarden_license/src/Sso/Startup.cs
index 2b45504543e0..ff36363ddc27 100644
--- a/bitwarden_license/src/Sso/Startup.cs
+++ b/bitwarden_license/src/Sso/Startup.cs
@@ -3,6 +3,7 @@
using Bit.Core.Context;
using Bit.Core.Settings;
using Bit.Core.Utilities;
+using Bit.SharedKernel.Utilities;
using Bit.SharedWeb.Utilities;
using Bit.Sso.Utilities;
using IdentityServer4.Extensions;
diff --git a/bitwarden_license/src/Sso/Views/Shared/_Layout.cshtml b/bitwarden_license/src/Sso/Views/Shared/_Layout.cshtml
index 4467f08f255c..46c6de335d91 100644
--- a/bitwarden_license/src/Sso/Views/Shared/_Layout.cshtml
+++ b/bitwarden_license/src/Sso/Views/Shared/_Layout.cshtml
@@ -1,4 +1,4 @@
-@using static Bit.Core.Utilities.CoreHelpers;
+@using static Bit.SharedKernel.Utilities.VersionHelper;
diff --git a/src/Admin/Controllers/HomeController.cs b/src/Admin/Controllers/HomeController.cs
index f2c899064c96..b9b7bdac3296 100644
--- a/src/Admin/Controllers/HomeController.cs
+++ b/src/Admin/Controllers/HomeController.cs
@@ -3,6 +3,7 @@
using System.Threading.Tasks;
using Bit.Admin.Models;
using Bit.Core.Settings;
+using Bit.SharedKernel.Utilities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
@@ -25,7 +26,7 @@ public IActionResult Index()
return View(new HomeModel
{
GlobalSettings = _globalSettings,
- CurrentVersion = Core.Utilities.CoreHelpers.GetVersion()
+ CurrentVersion = VersionHelper.GetVersion()
});
}
diff --git a/src/Admin/Controllers/InfoController.cs b/src/Admin/Controllers/InfoController.cs
index e09f0a9f3022..29870d18e4dc 100644
--- a/src/Admin/Controllers/InfoController.cs
+++ b/src/Admin/Controllers/InfoController.cs
@@ -1,5 +1,6 @@
using System;
using Bit.Core.Utilities;
+using Bit.SharedKernel.Utilities;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Admin.Controllers
@@ -16,7 +17,7 @@ public DateTime GetAlive()
[HttpGet("~/version")]
public JsonResult GetVersion()
{
- return Json(CoreHelpers.GetVersion());
+ return Json(VersionHelper.GetVersion());
}
}
}
diff --git a/src/Admin/Startup.cs b/src/Admin/Startup.cs
index 8ba71017b850..f2a3a984bf4b 100644
--- a/src/Admin/Startup.cs
+++ b/src/Admin/Startup.cs
@@ -4,6 +4,7 @@
using Bit.Core.Identity;
using Bit.Core.Settings;
using Bit.Core.Utilities;
+using Bit.SharedKernel.Utilities;
using Bit.SharedWeb.Utilities;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
diff --git a/src/Api/Controllers/InfoController.cs b/src/Api/Controllers/InfoController.cs
index 82aa7b938be3..bcedd2d469a5 100644
--- a/src/Api/Controllers/InfoController.cs
+++ b/src/Api/Controllers/InfoController.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Bit.Core.Utilities;
+using Bit.SharedKernel.Utilities;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Api.Controllers
@@ -18,7 +18,7 @@ public DateTime GetAlive()
[HttpGet("~/version")]
public JsonResult GetVersion()
{
- return Json(CoreHelpers.GetVersion());
+ return Json(VersionHelper.GetVersion());
}
[HttpGet("~/ip")]
diff --git a/src/Api/Startup.cs b/src/Api/Startup.cs
index 1953064071a0..2540b745f750 100644
--- a/src/Api/Startup.cs
+++ b/src/Api/Startup.cs
@@ -17,6 +17,7 @@
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
using System.Collections.Generic;
+using Bit.SharedKernel.Utilities;
using Bit.SharedWeb.Utilities;
#if !OSS
diff --git a/src/Billing/Controllers/InfoController.cs b/src/Billing/Controllers/InfoController.cs
index 016bee2c4d2a..92c26f1f0410 100644
--- a/src/Billing/Controllers/InfoController.cs
+++ b/src/Billing/Controllers/InfoController.cs
@@ -1,5 +1,5 @@
using System;
-using Bit.Core.Utilities;
+using Bit.SharedKernel.Utilities;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Billing.Controllers
@@ -16,7 +16,7 @@ public DateTime GetAlive()
[HttpGet("~/version")]
public JsonResult GetVersion()
{
- return Json(CoreHelpers.GetVersion());
+ return Json(VersionHelper.GetVersion());
}
}
}
diff --git a/src/Billing/Startup.cs b/src/Billing/Startup.cs
index 28f17ef8cba1..cee7ea74f96c 100644
--- a/src/Billing/Startup.cs
+++ b/src/Billing/Startup.cs
@@ -3,6 +3,7 @@
using Bit.Core.Context;
using Bit.Core.Settings;
using Bit.Core.Utilities;
+using Bit.SharedKernel.Utilities;
using Bit.SharedWeb.Utilities;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
diff --git a/src/Core/Core.csproj b/src/Core/Core.csproj
index b70d79092df3..79ebfa792e32 100644
--- a/src/Core/Core.csproj
+++ b/src/Core/Core.csproj
@@ -38,14 +38,8 @@
-
-
-
-
-
-
@@ -60,4 +54,8 @@
+
+
+
+
diff --git a/src/Core/Utilities/CoreHelpers.cs b/src/Core/Utilities/CoreHelpers.cs
index 315fecf113e9..d47d92983ec1 100644
--- a/src/Core/Utilities/CoreHelpers.cs
+++ b/src/Core/Utilities/CoreHelpers.cs
@@ -463,18 +463,6 @@ public static string FormatLicenseSignatureValue(object val)
return val.ToString();
}
- public static string GetVersion()
- {
- if (string.IsNullOrWhiteSpace(_version))
- {
- _version = Assembly.GetEntryAssembly()
- .GetCustomAttribute()
- .InformationalVersion;
- }
-
- return _version;
- }
-
public static string Dvorak2Qwerty(string value)
{
return Other2Qwerty(value, _dvorakMap, _qwertyDvorakMap);
diff --git a/src/Events/Controllers/InfoController.cs b/src/Events/Controllers/InfoController.cs
index 3a14ea6f7fb5..99133b10699c 100644
--- a/src/Events/Controllers/InfoController.cs
+++ b/src/Events/Controllers/InfoController.cs
@@ -1,5 +1,5 @@
using System;
-using Bit.Core.Utilities;
+using Bit.SharedKernel.Utilities;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Events.Controllers
@@ -16,7 +16,7 @@ public DateTime GetAlive()
[HttpGet("~/version")]
public JsonResult GetVersion()
{
- return Json(CoreHelpers.GetVersion());
+ return Json(VersionHelper.GetVersion());
}
}
}
diff --git a/src/Events/Startup.cs b/src/Events/Startup.cs
index 6cf103df690b..14bc16c12b6c 100644
--- a/src/Events/Startup.cs
+++ b/src/Events/Startup.cs
@@ -3,6 +3,7 @@
using Bit.Core.Services;
using Bit.Core.Settings;
using Bit.Core.Utilities;
+using Bit.SharedKernel.Utilities;
using Bit.SharedWeb.Utilities;
using IdentityModel;
using Microsoft.AspNetCore.Builder;
diff --git a/src/EventsProcessor/Startup.cs b/src/EventsProcessor/Startup.cs
index 32feb9de7ee0..04eab2500847 100644
--- a/src/EventsProcessor/Startup.cs
+++ b/src/EventsProcessor/Startup.cs
@@ -1,6 +1,7 @@
using System.Globalization;
using Bit.Core.Settings;
using Bit.Core.Utilities;
+using Bit.SharedKernel.Utilities;
using Bit.SharedWeb.Utilities;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
@@ -54,7 +55,7 @@ public void Configure(
endpoints.MapGet("/now",
async context => await context.Response.WriteAsJsonAsync(System.DateTime.UtcNow));
endpoints.MapGet("/version",
- async context => await context.Response.WriteAsJsonAsync(CoreHelpers.GetVersion()));
+ async context => await context.Response.WriteAsJsonAsync(VersionHelper.GetVersion()));
});
}
diff --git a/src/Icons/Controllers/InfoController.cs b/src/Icons/Controllers/InfoController.cs
index 7897569e8e27..fc36119e4b53 100644
--- a/src/Icons/Controllers/InfoController.cs
+++ b/src/Icons/Controllers/InfoController.cs
@@ -1,5 +1,5 @@
using System;
-using Bit.Core.Utilities;
+using Bit.SharedKernel.Utilities;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Icons.Controllers
@@ -16,7 +16,7 @@ public DateTime GetAlive()
[HttpGet("~/version")]
public JsonResult GetVersion()
{
- return Json(CoreHelpers.GetVersion());
+ return Json(VersionHelper.GetVersion());
}
}
}
diff --git a/src/Icons/Icons.csproj b/src/Icons/Icons.csproj
index 4e7f8a8497c1..6b6116edf1e5 100644
--- a/src/Icons/Icons.csproj
+++ b/src/Icons/Icons.csproj
@@ -14,8 +14,7 @@
-
-
+
diff --git a/src/Icons/Program.cs b/src/Icons/Program.cs
index 0fba981117fc..3aec0c7d60dc 100644
--- a/src/Icons/Program.cs
+++ b/src/Icons/Program.cs
@@ -1,7 +1,7 @@
-using Bit.Core.Utilities;
+using System;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
-using Serilog.Events;
+using Serilog;
namespace Bit.Icons
{
@@ -9,16 +9,33 @@ public class Program
{
public static void Main(string[] args)
{
- Host
- .CreateDefaultBuilder(args)
- .ConfigureWebHostDefaults(webBuilder =>
- {
- webBuilder.UseStartup();
- webBuilder.ConfigureLogging((hostingContext, logging) =>
- logging.AddSerilog(hostingContext, e => e.Level >= LogEventLevel.Error));
- })
- .Build()
- .Run();
+ Log.Logger = new LoggerConfiguration()
+ .WriteTo.Console()
+ .CreateBootstrapLogger();
+
+ try
+ {
+ Host
+ .CreateDefaultBuilder(args)
+ .UseSerilog((context, configuration) =>
+ {
+ configuration.ReadFrom.Configuration(context.Configuration);
+ })
+ .ConfigureWebHostDefaults(webBuilder =>
+ {
+ webBuilder.UseStartup();
+ })
+ .Build()
+ .Run();
+ }
+ catch (Exception ex)
+ {
+ Log.Fatal(ex, "Host terminated unexpectedly");
+ }
+ finally
+ {
+ Log.CloseAndFlush();
+ }
}
}
}
diff --git a/src/Icons/Startup.cs b/src/Icons/Startup.cs
index 5e5bb27820f7..71ff966815a9 100644
--- a/src/Icons/Startup.cs
+++ b/src/Icons/Startup.cs
@@ -1,9 +1,7 @@
using System;
using System.Globalization;
-using Bit.Core.Settings;
-using Bit.Core.Utilities;
using Bit.Icons.Services;
-using Bit.SharedWeb.Utilities;
+using Bit.SharedKernel.Utilities;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
@@ -30,10 +28,9 @@ public void ConfigureServices(IServiceCollection services)
services.AddOptions();
// Settings
- var globalSettings = services.AddGlobalSettingsServices(Configuration);
var iconsSettings = new IconsSettings();
ConfigurationBinder.Bind(Configuration.GetSection("IconsSettings"), iconsSettings);
- services.AddSingleton(s => iconsSettings);
+ services.AddSingleton(_ => iconsSettings);
// Cache
services.AddMemoryCache(options =>
@@ -52,11 +49,8 @@ public void ConfigureServices(IServiceCollection services)
public void Configure(
IApplicationBuilder app,
IWebHostEnvironment env,
- IHostApplicationLifetime appLifetime,
- GlobalSettings globalSettings)
+ IHostApplicationLifetime appLifetime)
{
- app.UseSerilog(env, appLifetime, globalSettings);
-
// Add general security headers
app.UseMiddleware();
diff --git a/src/Icons/appsettings.Development.json b/src/Icons/appsettings.Development.json
index fa8ce71a97a3..53f9e17ceee4 100644
--- a/src/Icons/appsettings.Development.json
+++ b/src/Icons/appsettings.Development.json
@@ -1,10 +1,7 @@
{
- "Logging": {
- "IncludeScopes": false,
- "LogLevel": {
- "Default": "Debug",
- "System": "Information",
- "Microsoft": "Information"
- }
+ "Serilog": {
+ "WriteTo": [
+ { "Name": "Console" }
+ ]
}
}
diff --git a/src/Icons/appsettings.Production.json b/src/Icons/appsettings.Production.json
index 437045a7fbb3..e1facf6fad1a 100644
--- a/src/Icons/appsettings.Production.json
+++ b/src/Icons/appsettings.Production.json
@@ -1,19 +1,7 @@
{
- "Logging": {
- "IncludeScopes": false,
- "LogLevel": {
- "Default": "Debug",
- "System": "Information",
- "Microsoft": "Information"
- },
- "Console": {
- "IncludeScopes": true,
- "LogLevel": {
- "Default": "Warning",
- "System": "Warning",
- "Microsoft": "Warning",
- "Microsoft.Hosting.Lifetime": "Information"
- }
+ "Serilog": {
+ "MinimumLevel": {
+ "Default": "Error"
}
}
}
diff --git a/src/Icons/appsettings.json b/src/Icons/appsettings.json
index 65267ef4e917..cf495b1947fa 100644
--- a/src/Icons/appsettings.json
+++ b/src/Icons/appsettings.json
@@ -10,5 +10,11 @@
"cacheEnabled": true,
"cacheHours": 24,
"cacheSizeLimit": null
+ },
+ "Serilog": {
+ "Enrich": [ "FromLogContext" ],
+ "Properties": {
+ "Project": "Icons"
+ }
}
}
diff --git a/src/Identity/Controllers/InfoController.cs b/src/Identity/Controllers/InfoController.cs
index 9824ac93a90d..e12daeb982a2 100644
--- a/src/Identity/Controllers/InfoController.cs
+++ b/src/Identity/Controllers/InfoController.cs
@@ -1,5 +1,5 @@
using System;
-using Bit.Core.Utilities;
+using Bit.SharedKernel.Utilities;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Identity.Controllers
@@ -16,7 +16,7 @@ public DateTime GetAlive()
[HttpGet("~/version")]
public JsonResult GetVersion()
{
- return Json(CoreHelpers.GetVersion());
+ return Json(VersionHelper.GetVersion());
}
}
}
diff --git a/src/Identity/Program.cs b/src/Identity/Program.cs
index a1397cd4ce5b..923adcad0143 100644
--- a/src/Identity/Program.cs
+++ b/src/Identity/Program.cs
@@ -1,8 +1,8 @@
-using AspNetCoreRateLimit;
+using System;
using Bit.Core.Utilities;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
-using Serilog.Events;
+using Serilog;
namespace Bit.Identity
{
@@ -10,33 +10,34 @@ public class Program
{
public static void Main(string[] args)
{
- Host
- .CreateDefaultBuilder(args)
- .ConfigureCustomAppConfiguration(args)
- .ConfigureWebHostDefaults(webBuilder =>
- {
- webBuilder.UseStartup();
- webBuilder.ConfigureLogging((hostingContext, logging) =>
- logging.AddSerilog(hostingContext, e =>
- {
- var context = e.Properties["SourceContext"].ToString();
- if (context.Contains(typeof(IpRateLimitMiddleware).FullName) &&
- e.Level == LogEventLevel.Information)
- {
- return true;
- }
+ Log.Logger = new LoggerConfiguration()
+ .WriteTo.Console()
+ .CreateBootstrapLogger();
- if (context.Contains("IdentityServer4.Validation.TokenValidator") ||
- context.Contains("IdentityServer4.Validation.TokenRequestValidator"))
- {
- return e.Level > LogEventLevel.Error;
- }
-
- return e.Level >= LogEventLevel.Error;
- }));
- })
- .Build()
- .Run();
+ try
+ {
+ Host
+ .CreateDefaultBuilder(args)
+ .ConfigureCustomAppConfiguration(args)
+ .UseSerilog((context, configuration) =>
+ {
+ configuration.ReadFrom.Configuration(context.Configuration);
+ })
+ .ConfigureWebHostDefaults(webBuilder =>
+ {
+ webBuilder.UseStartup();
+ })
+ .Build()
+ .Run();
+ }
+ catch (Exception ex)
+ {
+ Log.Fatal(ex, "Host terminated unexpectedly");
+ }
+ finally
+ {
+ Log.CloseAndFlush();
+ }
}
}
}
diff --git a/src/Identity/Startup.cs b/src/Identity/Startup.cs
index 7584bf99f3eb..5d1f702efdaf 100644
--- a/src/Identity/Startup.cs
+++ b/src/Identity/Startup.cs
@@ -8,6 +8,7 @@
using Bit.Core.Settings;
using Bit.Core.Utilities;
using Bit.Identity.Utilities;
+using Bit.SharedKernel.Utilities;
using Bit.SharedWeb.Utilities;
using IdentityServer4.Extensions;
using Microsoft.AspNetCore.Builder;
diff --git a/src/Identity/appsettings.Development.json b/src/Identity/appsettings.Development.json
index 950c72818782..2e162080fac8 100644
--- a/src/Identity/appsettings.Development.json
+++ b/src/Identity/appsettings.Development.json
@@ -26,5 +26,10 @@
"storage": {
"connectionString": "UseDevelopmentStorage=true"
}
+ },
+ "Serilog": {
+ "WriteTo": [
+ { "Name": "Console" }
+ ]
}
}
diff --git a/src/Identity/appsettings.Production.json b/src/Identity/appsettings.Production.json
index 4f05fcec9f25..6d7588f1e7c7 100644
--- a/src/Identity/appsettings.Production.json
+++ b/src/Identity/appsettings.Production.json
@@ -18,21 +18,11 @@
"production": true
}
},
- "Logging": {
- "IncludeScopes": false,
- "LogLevel": {
- "Default": "Debug",
- "System": "Information",
- "Microsoft": "Information"
- },
- "Console": {
- "IncludeScopes": true,
- "LogLevel": {
- "Default": "Warning",
- "System": "Warning",
- "Microsoft": "Warning",
- "Microsoft.Hosting.Lifetime": "Information"
- }
+ "Serilog": {
+ "MinimumLevel": {
+ "Default": "Error",
+ "IdentityServer4.Validation.TokenValidator": "Fatal",
+ "IdentityServer4.Validation.TokenRequestValidator": "Fatal"
}
}
}
diff --git a/src/Identity/appsettings.json b/src/Identity/appsettings.json
index fb3469b5fe11..6b1dcbb1b96f 100644
--- a/src/Identity/appsettings.json
+++ b/src/Identity/appsettings.json
@@ -90,5 +90,11 @@
},
"IpRateLimitPolicies": {
"IpRules": []
+ },
+ "Serilog": {
+ "Enrich": [ "FromLogContext" ],
+ "Properties": {
+ "Project": "Identity"
+ }
}
}
diff --git a/src/Notifications/Controllers/InfoController.cs b/src/Notifications/Controllers/InfoController.cs
index d9169724316d..3c9b8d13a503 100644
--- a/src/Notifications/Controllers/InfoController.cs
+++ b/src/Notifications/Controllers/InfoController.cs
@@ -1,5 +1,5 @@
using System;
-using Bit.Core.Utilities;
+using Bit.SharedKernel.Utilities;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Notifications.Controllers
@@ -16,7 +16,7 @@ public DateTime GetAlive()
[HttpGet("~/version")]
public JsonResult GetVersion()
{
- return Json(CoreHelpers.GetVersion());
+ return Json(VersionHelper.GetVersion());
}
}
}
diff --git a/src/Notifications/Startup.cs b/src/Notifications/Startup.cs
index 4ca7b728ecb9..6a1f4477821e 100644
--- a/src/Notifications/Startup.cs
+++ b/src/Notifications/Startup.cs
@@ -2,6 +2,7 @@
using System.Globalization;
using Bit.Core.Settings;
using Bit.Core.Utilities;
+using Bit.SharedKernel.Utilities;
using Bit.SharedWeb.Utilities;
using IdentityModel;
using Microsoft.AspNetCore.Builder;
diff --git a/src/SharedKernel/SharedKernel.csproj b/src/SharedKernel/SharedKernel.csproj
new file mode 100644
index 000000000000..cd14aae77f11
--- /dev/null
+++ b/src/SharedKernel/SharedKernel.csproj
@@ -0,0 +1,16 @@
+
+
+
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Core/Utilities/SecurityHeadersMiddleware.cs b/src/SharedKernel/Utilities/SecurityHeadersMiddleware.cs
similarity index 96%
rename from src/Core/Utilities/SecurityHeadersMiddleware.cs
rename to src/SharedKernel/Utilities/SecurityHeadersMiddleware.cs
index 2f11ee3315db..cc4b25b20535 100644
--- a/src/Core/Utilities/SecurityHeadersMiddleware.cs
+++ b/src/SharedKernel/Utilities/SecurityHeadersMiddleware.cs
@@ -2,7 +2,7 @@
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives;
-namespace Bit.Core.Utilities
+namespace Bit.SharedKernel.Utilities
{
public sealed class SecurityHeadersMiddleware
{
diff --git a/src/SharedKernel/Utilities/VersionHelper.cs b/src/SharedKernel/Utilities/VersionHelper.cs
new file mode 100644
index 000000000000..a5a2b1a4a013
--- /dev/null
+++ b/src/SharedKernel/Utilities/VersionHelper.cs
@@ -0,0 +1,21 @@
+using System.Reflection;
+
+namespace Bit.SharedKernel.Utilities
+{
+ public static class VersionHelper
+ {
+ private static string? _version;
+
+ public static string GetVersion()
+ {
+ if (string.IsNullOrWhiteSpace(_version))
+ {
+ _version = Assembly.GetEntryAssembly()!
+ .GetCustomAttribute()!
+ .InformationalVersion;
+ }
+
+ return _version;
+ }
+ }
+}
diff --git a/src/SharedWeb/Utilities/ServiceCollectionExtensions.cs b/src/SharedWeb/Utilities/ServiceCollectionExtensions.cs
index 418e7655e397..9537385a5c95 100644
--- a/src/SharedWeb/Utilities/ServiceCollectionExtensions.cs
+++ b/src/SharedWeb/Utilities/ServiceCollectionExtensions.cs
@@ -17,6 +17,7 @@
using Bit.Core.Utilities;
using Bit.Infrastructure.Dapper;
using Bit.Infrastructure.EntityFramework;
+using Bit.SharedKernel.Utilities;
using IdentityModel;
using IdentityServer4.AccessTokenValidation;
using IdentityServer4.Configuration;
@@ -496,7 +497,7 @@ string GetHeaderValue(HttpContext httpContext, string header)
{
httpContext.Response.OnStarting((state) =>
{
- httpContext.Response.Headers.Append("Server-Version", CoreHelpers.GetVersion());
+ httpContext.Response.Headers.Append("Server-Version", VersionHelper.GetVersion());
return Task.FromResult(0);
}, null);
await next.Invoke();