Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove icon service dependency on core #77

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions bitwarden-server.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down
4 changes: 2 additions & 2 deletions bitwarden_license/src/Sso/Controllers/InfoController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Bit.Core.Utilities;
using Bit.SharedKernel.Utilities;
using Microsoft.AspNetCore.Mvc;

namespace Bit.Sso.Controllers
Expand All @@ -16,7 +16,7 @@ public DateTime GetAlive()
[HttpGet("~/version")]
public JsonResult GetVersion()
{
return Json(CoreHelpers.GetVersion());
return Json(VersionHelper.GetVersion());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: VersionHelper.GetVersion() is now used instead of CoreHelpers.GetVersion(). Verify that VersionHelper provides the same functionality and returns the version in the expected format.

}
}
}
1 change: 1 addition & 0 deletions bitwarden_license/src/Sso/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion bitwarden_license/src/Sso/Views/Shared/_Layout.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@using static Bit.Core.Utilities.CoreHelpers;
@using static Bit.SharedKernel.Utilities.VersionHelper;

<!DOCTYPE html>
<html lang="en">
Expand Down
3 changes: 2 additions & 1 deletion src/Admin/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -25,7 +26,7 @@ public IActionResult Index()
return View(new HomeModel
{
GlobalSettings = _globalSettings,
CurrentVersion = Core.Utilities.CoreHelpers.GetVersion()
CurrentVersion = VersionHelper.GetVersion()
});
}

Expand Down
3 changes: 2 additions & 1 deletion src/Admin/Controllers/InfoController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using Bit.Core.Utilities;
using Bit.SharedKernel.Utilities;
using Microsoft.AspNetCore.Mvc;

namespace Bit.Admin.Controllers
Expand All @@ -16,7 +17,7 @@ public DateTime GetAlive()
[HttpGet("~/version")]
public JsonResult GetVersion()
{
return Json(CoreHelpers.GetVersion());
return Json(VersionHelper.GetVersion());
}
}
}
1 change: 1 addition & 0 deletions src/Admin/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/Api/Controllers/InfoController.cs
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,7 +18,7 @@ public DateTime GetAlive()
[HttpGet("~/version")]
public JsonResult GetVersion()
{
return Json(CoreHelpers.GetVersion());
return Json(VersionHelper.GetVersion());
}

[HttpGet("~/ip")]
Expand Down
1 change: 1 addition & 0 deletions src/Api/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Billing/Controllers/InfoController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Bit.Core.Utilities;
using Bit.SharedKernel.Utilities;
using Microsoft.AspNetCore.Mvc;

namespace Bit.Billing.Controllers
Expand All @@ -16,7 +16,7 @@ public DateTime GetAlive()
[HttpGet("~/version")]
public JsonResult GetVersion()
{
return Json(CoreHelpers.GetVersion());
return Json(VersionHelper.GetVersion());
}
}
}
1 change: 1 addition & 0 deletions src/Billing/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 4 additions & 6 deletions src/Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,8 @@
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="5.0.9" />
<PackageReference Include="Quartz" Version="3.1.0" />
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.0.1" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="2.0.0" />
<PackageReference Include="Sentry.Serilog" Version="2.1.5" />
<PackageReference Include="IdentityServer4" Version="4.0.4" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Serilog.Sinks.AzureCosmosDB" Version="1.0.0" />
<PackageReference Include="Serilog.Sinks.SyslogMessages" Version="1.0.5" />
<PackageReference Include="System.Text.Json" Version="4.7.2" />
<PackageReference Include="AspNetCoreRateLimit" Version="2.1.0" />
<PackageReference Include="Braintree" Version="4.18.0" />
Expand All @@ -60,4 +54,8 @@
<Folder Include="Resources\" />
<Folder Include="Properties\" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\SharedKernel\SharedKernel.csproj" />
</ItemGroup>
</Project>
12 changes: 0 additions & 12 deletions src/Core/Utilities/CoreHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<AssemblyInformationalVersionAttribute>()
.InformationalVersion;
}

return _version;
}

public static string Dvorak2Qwerty(string value)
{
return Other2Qwerty(value, _dvorakMap, _qwertyDvorakMap);
Expand Down
4 changes: 2 additions & 2 deletions src/Events/Controllers/InfoController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Bit.Core.Utilities;
using Bit.SharedKernel.Utilities;
using Microsoft.AspNetCore.Mvc;

namespace Bit.Events.Controllers
Expand All @@ -16,7 +16,7 @@ public DateTime GetAlive()
[HttpGet("~/version")]
public JsonResult GetVersion()
{
return Json(CoreHelpers.GetVersion());
return Json(VersionHelper.GetVersion());
}
}
}
1 change: 1 addition & 0 deletions src/Events/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion src/EventsProcessor/Startup.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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()));

});
}
Expand Down
4 changes: 2 additions & 2 deletions src/Icons/Controllers/InfoController.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Bit.Core.Utilities;
using Bit.SharedKernel.Utilities;
using Microsoft.AspNetCore.Mvc;

namespace Bit.Icons.Controllers
Expand All @@ -16,7 +16,7 @@ public DateTime GetAlive()
[HttpGet("~/version")]
public JsonResult GetVersion()
{
return Json(CoreHelpers.GetVersion());
return Json(VersionHelper.GetVersion());
}
}
}
3 changes: 1 addition & 2 deletions src/Icons/Icons.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\SharedWeb\SharedWeb.csproj" />
<ProjectReference Include="..\Core\Core.csproj" />
<ProjectReference Include="..\SharedKernel\SharedKernel.csproj" />
</ItemGroup>

</Project>
41 changes: 29 additions & 12 deletions src/Icons/Program.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
using Bit.Core.Utilities;
using System;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Serilog.Events;
using Serilog;

namespace Bit.Icons
{
public class Program
{
public static void Main(string[] args)
{
Host
.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
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<Startup>();
})
.Build()
.Run();
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly");
}
finally
{
Log.CloseAndFlush();
}
}
}
}
12 changes: 3 additions & 9 deletions src/Icons/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider adding XML comments for public methods and classes to maintain documentation standards.

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;
Expand All @@ -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 =>
Expand All @@ -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<SecurityHeadersMiddleware>();

Expand Down
11 changes: 4 additions & 7 deletions src/Icons/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
"Serilog": {
"WriteTo": [
{ "Name": "Console" }
]
}
}
18 changes: 3 additions & 15 deletions src/Icons/appsettings.Production.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
Comment on lines 1 to 7
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Ensure that this Serilog configuration is consistent with other services and provides sufficient logging information for production troubleshooting.

Loading
Loading