mirror of
https://github.com/bitwarden/server.git
synced 2025-02-13 01:21:29 +01:00
80 lines
2.3 KiB
C#
80 lines
2.3 KiB
C#
using Bit.Core;
|
|
using Bit.Core.Utilities;
|
|
using Bit.Scim.Utilities;
|
|
using Microsoft.ApplicationInsights.Extensibility;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
|
using Microsoft.Extensions.Logging;
|
|
using Serilog.Events;
|
|
|
|
namespace Bit.Scim
|
|
{
|
|
public class Startup
|
|
{
|
|
public Startup(IConfiguration configuration)
|
|
{
|
|
Configuration = configuration;
|
|
}
|
|
|
|
public IConfiguration Configuration { get; }
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
{
|
|
// Options
|
|
services.AddOptions();
|
|
|
|
// Settings
|
|
var globalSettings = services.AddGlobalSettingsServices(Configuration);
|
|
|
|
// Repositories
|
|
services.AddSqlServerRepositories(globalSettings);
|
|
|
|
// Context
|
|
services.AddScoped<CurrentContext>();
|
|
|
|
// Identity
|
|
services.AddCustomIdentityServices(globalSettings);
|
|
|
|
// Services
|
|
services.AddBaseServices();
|
|
services.AddDefaultServices(globalSettings);
|
|
|
|
services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
|
|
|
|
// Mvc
|
|
services.AddMvc(config =>
|
|
{
|
|
config.Filters.Add(new ExceptionHandlerFilterAttribute());
|
|
});
|
|
}
|
|
|
|
public void Configure(
|
|
IApplicationBuilder app,
|
|
IHostingEnvironment env,
|
|
IApplicationLifetime appLifetime,
|
|
GlobalSettings globalSettings,
|
|
ILoggerFactory loggerFactory)
|
|
{
|
|
// Disable app insights
|
|
var telConfig = app.ApplicationServices.GetService<TelemetryConfiguration>();
|
|
telConfig.DisableTelemetry = true;
|
|
|
|
loggerFactory.AddSerilog(env, appLifetime, globalSettings, (e) => e.Level >= LogEventLevel.Error);
|
|
|
|
if(env.IsDevelopment())
|
|
{
|
|
app.UseDeveloperExceptionPage();
|
|
}
|
|
|
|
// Default Middleware
|
|
app.UseDefaultMiddleware(env);
|
|
|
|
app.UseMvc();
|
|
}
|
|
}
|
|
}
|