mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 00:52:49 -05:00
centralize a lot of service registration
This commit is contained in:
@ -4,10 +4,13 @@
|
||||
<TargetFramework>net461</TargetFramework>
|
||||
<AssemblyName>Identity</AssemblyName>
|
||||
<RootNamespace>Bit.Identity</RootNamespace>
|
||||
<UserSecretsId>527b1fab-a4b5-465b-881a-f44f08c42899</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.1.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -4,24 +4,84 @@ using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Bit.Core;
|
||||
using Bit.Core.Utilities;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace Bit.Identity
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
public Startup(IHostingEnvironment env)
|
||||
{
|
||||
var builder = new ConfigurationBuilder()
|
||||
.SetBasePath(env.ContentRootPath)
|
||||
.AddJsonFile("settings.json")
|
||||
.AddJsonFile($"settings.{env.EnvironmentName}.json", optional: true);
|
||||
|
||||
if(env.IsDevelopment())
|
||||
{
|
||||
builder.AddUserSecrets<Startup>();
|
||||
}
|
||||
|
||||
builder.AddEnvironmentVariables();
|
||||
|
||||
Configuration = builder.Build();
|
||||
Environment = env;
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
||||
public IConfigurationRoot Configuration { get; private set; }
|
||||
public IHostingEnvironment Environment { get; set; }
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
loggerFactory.AddConsole();
|
||||
// Options
|
||||
services.AddOptions();
|
||||
|
||||
// Settings
|
||||
var globalSettings = services.AddGlobalSettingsServices(Configuration);
|
||||
|
||||
// Data Protection
|
||||
services.AddCustomDataProtectionServices(Environment, globalSettings);
|
||||
|
||||
// Repositories
|
||||
services.AddSqlServerRepositories();
|
||||
|
||||
// Context
|
||||
services.AddScoped<CurrentContext>();
|
||||
|
||||
// IdentityServer
|
||||
services.AddCustomIdentityServerServices(Environment, globalSettings);
|
||||
|
||||
// Identity
|
||||
services.AddCustomIdentityServices(globalSettings);
|
||||
|
||||
// Services
|
||||
services.AddBaseServices();
|
||||
services.AddDefaultServices();
|
||||
}
|
||||
|
||||
public void Configure(
|
||||
IApplicationBuilder app,
|
||||
IHostingEnvironment env,
|
||||
ILoggerFactory loggerFactory,
|
||||
IApplicationLifetime appLifetime,
|
||||
GlobalSettings globalSettings)
|
||||
{
|
||||
loggerFactory
|
||||
.AddSerilog(env, appLifetime, globalSettings, (e) => e.Level >= LogEventLevel.Error)
|
||||
.AddConsole()
|
||||
.AddDebug();
|
||||
|
||||
if(env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
// Add IdentityServer to the request pipeline.
|
||||
app.UseIdentityServer();
|
||||
|
||||
app.Run(async (context) =>
|
||||
{
|
||||
await context.Response.WriteAsync("Hello World!");
|
||||
|
5
src/Identity/settings.Preview.json
Normal file
5
src/Identity/settings.Preview.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"globalSettings": {
|
||||
"baseVaultUri": "https://preview-vault.bitwarden.com/#"
|
||||
}
|
||||
}
|
5
src/Identity/settings.Production.json
Normal file
5
src/Identity/settings.Production.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"globalSettings": {
|
||||
"baseVaultUri": "https://vault.bitwarden.com/#"
|
||||
}
|
||||
}
|
5
src/Identity/settings.Staging.json
Normal file
5
src/Identity/settings.Staging.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"globalSettings": {
|
||||
"baseVaultUri": "https://vault.bitwarden.com/#"
|
||||
}
|
||||
}
|
35
src/Identity/settings.json
Normal file
35
src/Identity/settings.json
Normal file
@ -0,0 +1,35 @@
|
||||
{
|
||||
"globalSettings": {
|
||||
"siteName": "bitwarden",
|
||||
"baseVaultUri": "http://localhost:4001/#",
|
||||
"jwtSigningKey": "THIS IS A SECRET. IT KEEPS YOUR TOKEN SAFE. :)",
|
||||
"stripeApiKey": "SECRET",
|
||||
"sqlServer": {
|
||||
"connectionString": "SECRET"
|
||||
},
|
||||
"mail": {
|
||||
"apiKey": "SECRET",
|
||||
"replyToEmail": "hello@bitwarden.com"
|
||||
},
|
||||
"push": {
|
||||
"apnsCertificateThumbprint": "SECRET",
|
||||
"apnsCertificatePassword": "SECRET",
|
||||
"gcmSenderId": "SECRET",
|
||||
"gcmApiKey": "SECRET",
|
||||
"gcmAppPackageName": "com.x8bit.bitwarden"
|
||||
},
|
||||
"identityServer": {
|
||||
"certificateThumbprint": "SECRET"
|
||||
},
|
||||
"dataProtection": {
|
||||
"certificateThumbprint": "SECRET"
|
||||
},
|
||||
"storage": {
|
||||
"connectionString": "SECRET"
|
||||
},
|
||||
"documentDb": {
|
||||
"uri": "SECRET",
|
||||
"key": "SECRET"
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user