mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 08:32:50 -05:00
stubbed out jobs worker console app
This commit is contained in:
@ -14,7 +14,7 @@ namespace Bit.Core.Utilities
|
||||
.AddJsonFile("settings.json")
|
||||
.AddJsonFile($"settings.{env.EnvironmentName}.json", optional: true);
|
||||
|
||||
if(env.IsDevelopment())
|
||||
if(env.IsDevelopment() && !string.IsNullOrWhiteSpace(userSecretsId))
|
||||
{
|
||||
builder.AddUserSecrets(userSecretsId);
|
||||
}
|
||||
|
@ -7,7 +7,6 @@ using Microsoft.Extensions.Configuration;
|
||||
using Bit.Core;
|
||||
using Bit.Core.Utilities;
|
||||
using Serilog.Events;
|
||||
using Microsoft.AspNetCore.HttpOverrides;
|
||||
|
||||
namespace Bit.Identity
|
||||
{
|
||||
|
20
src/Jobs/Jobs.csproj
Normal file
20
src/Jobs/Jobs.csproj
Normal file
@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
<AssemblyName>Jobs</AssemblyName>
|
||||
<RootNamespace>Bit.Jobs</RootNamespace>
|
||||
<UserSecretsId>bitwarden-Jobs</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Core\Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
16
src/Jobs/NoopServer.cs
Normal file
16
src/Jobs/NoopServer.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using Microsoft.AspNetCore.Hosting.Server;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
|
||||
namespace Bit.Jobs
|
||||
{
|
||||
public class NoopServer : IServer
|
||||
{
|
||||
public IFeatureCollection Features => new FeatureCollection();
|
||||
|
||||
public void Dispose()
|
||||
{ }
|
||||
|
||||
public void Start<TContext>(IHttpApplication<TContext> application)
|
||||
{ }
|
||||
}
|
||||
}
|
46
src/Jobs/Program.cs
Normal file
46
src/Jobs/Program.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using Bit.Core.Services;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Bit.Jobs
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
private static ILicensingService _licensingService;
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var host = new WebHostBuilder()
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseStartup<Startup>()
|
||||
.UseServer(new NoopServer())
|
||||
.Build();
|
||||
|
||||
_licensingService = host.Services.GetRequiredService<ILicensingService>();
|
||||
|
||||
MainAsync(args).Wait();
|
||||
}
|
||||
|
||||
private async static Task MainAsync(string[] args)
|
||||
{
|
||||
if(args.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch(args[0])
|
||||
{
|
||||
case "validate-licenses":
|
||||
await _licensingService.ValidateOrganizationsAsync();
|
||||
break;
|
||||
case "refresh-licenses":
|
||||
// TODO
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
12
src/Jobs/Properties/launchSettings.json
Normal file
12
src/Jobs/Properties/launchSettings.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"profiles": {
|
||||
"Jobs": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": false,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "http://localhost:4409/"
|
||||
}
|
||||
}
|
||||
}
|
63
src/Jobs/Startup.cs
Normal file
63
src/Jobs/Startup.cs
Normal file
@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Bit.Core;
|
||||
using Bit.Core.Utilities;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
|
||||
namespace Bit.Jobs
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IHostingEnvironment env)
|
||||
{
|
||||
var builder = new ConfigurationBuilder()
|
||||
.AddSettingsConfiguration(env, "bitwarden-Jobs");
|
||||
Configuration = builder.Build();
|
||||
Environment = env;
|
||||
}
|
||||
|
||||
public IConfigurationRoot Configuration { get; private set; }
|
||||
public IHostingEnvironment Environment { get; set; }
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
// Options
|
||||
services.AddOptions();
|
||||
|
||||
// Settings
|
||||
var globalSettings = services.AddGlobalSettingsServices(Configuration);
|
||||
|
||||
// Data Protection
|
||||
services.AddCustomDataProtectionServices(Environment, globalSettings);
|
||||
|
||||
// Repositories
|
||||
services.AddSqlServerRepositories();
|
||||
|
||||
// Context
|
||||
services.AddScoped<CurrentContext>();
|
||||
|
||||
// Identity
|
||||
services.AddCustomIdentityServices(globalSettings);
|
||||
|
||||
// Services
|
||||
services.AddBaseServices();
|
||||
services.AddDefaultServices(globalSettings);
|
||||
}
|
||||
|
||||
public void Configure(
|
||||
IApplicationBuilder app,
|
||||
IHostingEnvironment env,
|
||||
ILoggerFactory loggerFactory,
|
||||
IApplicationLifetime appLifetime,
|
||||
GlobalSettings globalSettings)
|
||||
{
|
||||
loggerFactory
|
||||
.AddSerilog(env, appLifetime, globalSettings)
|
||||
.AddConsole()
|
||||
.AddDebug();
|
||||
}
|
||||
}
|
||||
}
|
10
src/Jobs/settings.Preview.json
Normal file
10
src/Jobs/settings.Preview.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"globalSettings": {
|
||||
"baseServiceUri": {
|
||||
"vault": "https://preview-vault.bitwarden.com",
|
||||
"api": "https://preview-api.bitwarden.com",
|
||||
"identity": "https://preview-identity.bitwarden.com",
|
||||
"identityInternal": "https://preview-identity.bitwarden.com"
|
||||
}
|
||||
}
|
||||
}
|
13
src/Jobs/settings.Production.json
Normal file
13
src/Jobs/settings.Production.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"globalSettings": {
|
||||
"baseServiceUri": {
|
||||
"vault": "https://vault.bitwarden.com",
|
||||
"api": "https://api.bitwarden.com",
|
||||
"identity": "https://identity.bitwarden.com",
|
||||
"identityInternal": "https://identity.bitwarden.com"
|
||||
},
|
||||
"braintree": {
|
||||
"production": true
|
||||
}
|
||||
}
|
||||
}
|
10
src/Jobs/settings.Staging.json
Normal file
10
src/Jobs/settings.Staging.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"globalSettings": {
|
||||
"baseServiceUri": {
|
||||
"vault": "https://vault.bitwarden.com",
|
||||
"api": "https://api.bitwarden.com",
|
||||
"identity": "https://identity.bitwarden.com",
|
||||
"identityInternal": "https://identity.bitwarden.com"
|
||||
}
|
||||
}
|
||||
}
|
51
src/Jobs/settings.json
Normal file
51
src/Jobs/settings.json
Normal file
@ -0,0 +1,51 @@
|
||||
{
|
||||
"globalSettings": {
|
||||
"selfHosted": false,
|
||||
"siteName": "bitwarden",
|
||||
"projectName": "Jobs",
|
||||
"stripeApiKey": "SECRET",
|
||||
"baseServiceUri": {
|
||||
"vault": "http://localhost:4001",
|
||||
"api": "http://localhost:4000",
|
||||
"identity": "http://localhost:33656",
|
||||
"internalIdentity": "http://localhost:33656"
|
||||
},
|
||||
"sqlServer": {
|
||||
"connectionString": "SECRET"
|
||||
},
|
||||
"mail": {
|
||||
"sendGridApiKey": "SECRET",
|
||||
"replyToEmail": "hello@bitwarden.com"
|
||||
},
|
||||
"identityServer": {
|
||||
"certificateThumbprint": "SECRET"
|
||||
},
|
||||
"dataProtection": {
|
||||
"certificateThumbprint": "SECRET"
|
||||
},
|
||||
"storage": {
|
||||
"connectionString": "SECRET"
|
||||
},
|
||||
"documentDb": {
|
||||
"uri": "SECRET",
|
||||
"key": "SECRET"
|
||||
},
|
||||
"notificationHub": {
|
||||
"connectionString": "SECRET",
|
||||
"hubName": "SECRET"
|
||||
},
|
||||
"yubico": {
|
||||
"clientid": "SECRET",
|
||||
"key": "SECRET"
|
||||
},
|
||||
"duo": {
|
||||
"aKey": "SECRET"
|
||||
},
|
||||
"braintree": {
|
||||
"production": false,
|
||||
"merchantId": "SECRET",
|
||||
"publicKey": "SECRET",
|
||||
"privateKey": "SECRET"
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user