mirror of
https://github.com/bitwarden/server.git
synced 2025-07-14 22:27:32 -05:00
upgrade to aspnet core 3.1
This commit is contained in:
@ -8,13 +8,14 @@ using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.IdentityModel.Logging;
|
||||
|
||||
namespace Bit.Notifications
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IHostingEnvironment env, IConfiguration configuration)
|
||||
public Startup(IWebHostEnvironment env, IConfiguration configuration)
|
||||
{
|
||||
CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
|
||||
Configuration = configuration;
|
||||
@ -22,7 +23,7 @@ namespace Bit.Notifications
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
public IHostingEnvironment Environment { get; set; }
|
||||
public IWebHostEnvironment Environment { get; set; }
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
@ -81,8 +82,8 @@ namespace Bit.Notifications
|
||||
|
||||
public void Configure(
|
||||
IApplicationBuilder app,
|
||||
IHostingEnvironment env,
|
||||
IApplicationLifetime appLifetime,
|
||||
IWebHostEnvironment env,
|
||||
IHostApplicationLifetime appLifetime,
|
||||
GlobalSettings globalSettings)
|
||||
{
|
||||
IdentityModelEventSource.ShowPII = true;
|
||||
@ -93,29 +94,38 @@ namespace Bit.Notifications
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
// Add routing
|
||||
app.UseRouting();
|
||||
|
||||
// Add Cors
|
||||
app.UseCors(policy => policy.SetIsOriginAllowed(h => true)
|
||||
.AllowAnyMethod().AllowAnyHeader().AllowCredentials());
|
||||
|
||||
// Add authentication to the request pipeline.
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
// Add SignlarR
|
||||
if(!string.IsNullOrWhiteSpace(globalSettings.Notifications?.AzureSignalRConnectionString))
|
||||
var useAzureSignalR = !string.IsNullOrWhiteSpace(
|
||||
globalSettings.Notifications?.AzureSignalRConnectionString);
|
||||
if(useAzureSignalR)
|
||||
{
|
||||
app.UseAzureSignalR(routes => routes.MapHub<NotificationsHub>("/hub"));
|
||||
}
|
||||
else
|
||||
{
|
||||
app.UseSignalR(routes => routes.MapHub<NotificationsHub>("/hub", options =>
|
||||
{
|
||||
options.ApplicationMaxBufferSize = 2048; // client => server messages are not even used
|
||||
options.TransportMaxBufferSize = 4096;
|
||||
}));
|
||||
}
|
||||
|
||||
// Add MVC to the request pipeline.
|
||||
app.UseMvc();
|
||||
// Add endpoints to the request pipeline.
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
if(!useAzureSignalR)
|
||||
{
|
||||
endpoints.MapHub<NotificationsHub>("/hub", options =>
|
||||
{
|
||||
options.ApplicationMaxBufferSize = 2048; // client => server messages are not even used
|
||||
options.TransportMaxBufferSize = 4096;
|
||||
});
|
||||
}
|
||||
endpoints.MapDefaultControllerRoute();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user