Merge branch 'secrets-migration' into dev

This commit is contained in:
Daniel Harvey
2026-05-18 17:52:04 -04:00
5 changed files with 27 additions and 15 deletions
+5 -1
View File
@@ -9,11 +9,15 @@ using DeepDrftContent.Services.FileDatabase.Services;
using DeepDrftContent.Services.Processors; using DeepDrftContent.Services.Processors;
using DeepDrftCli.Services; using DeepDrftCli.Services;
using DeepDrftCli.Models; using DeepDrftCli.Models;
using NetBlocks.Utilities.Environment;
var builder = Host.CreateApplicationBuilder(args); var builder = Host.CreateApplicationBuilder(args);
// Load configuration from environment/config.json // Load configuration from environment/config.json
builder.Configuration.AddJsonFile($"{AppDomain.CurrentDomain.BaseDirectory}environment/connections.json", optional: false, reloadOnChange: true); var connectionsPath = CredentialTools.ResolvePathOrThrow(
"connections",
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "environment", "connections.json"));
builder.Configuration.AddJsonFile(connectionsPath, optional: false, reloadOnChange: false);
var cliSettings = builder.Configuration.GetSection(nameof(CliSettings)).Get<CliSettings>(); var cliSettings = builder.Configuration.GetSection(nameof(CliSettings)).Get<CliSettings>();
if (cliSettings is null) { throw new Exception("CLI settings are not configured"); } if (cliSettings is null) { throw new Exception("CLI settings are not configured"); }
+4 -2
View File
@@ -3,6 +3,7 @@ using DeepDrftContent.Services.FileDatabase.Services;
using DeepDrftContent.Middleware; using DeepDrftContent.Middleware;
using DeepDrftContent.Models; using DeepDrftContent.Models;
using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.HttpOverrides;
using NetBlocks.Utilities.Environment;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
@@ -31,8 +32,9 @@ builder.Services.AddCors(options =>
}); });
}); });
// Load API key configuration // Load API key via CredentialTools (dev: environment/apikey.json; prod: CREDENTIALS_DIRECTORY/apikey)
builder.Configuration.AddJsonFile("environment/apikey.json", optional: false, reloadOnChange: true); var apiKeyPath = CredentialTools.ResolvePathOrThrow("apikey", "environment/apikey.json");
builder.Configuration.AddJsonFile(apiKeyPath, optional: false, reloadOnChange: false);
var apiKeySettings = builder.Configuration.GetSection(nameof(ApiKeySettings)).Get<ApiKeySettings>(); var apiKeySettings = builder.Configuration.GetSection(nameof(ApiKeySettings)).Get<ApiKeySettings>();
if (apiKeySettings is null) { throw new Exception("API key settings are not configured"); } if (apiKeySettings is null) { throw new Exception("API key settings are not configured"); }
+3 -1
View File
@@ -6,6 +6,7 @@ using DeepDrftContent.Services.FileDatabase.Services;
using DeepDrftContent.Services.Processors; using DeepDrftContent.Services.Processors;
using DeepDrftContent.Models; using DeepDrftContent.Models;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using NetBlocks.Utilities.Environment;
namespace DeepDrftContent namespace DeepDrftContent
{ {
@@ -19,7 +20,8 @@ namespace DeepDrftContent
builder.Services.AddSingleton<TrackService>(); builder.Services.AddSingleton<TrackService>();
// File Database // File Database
builder.Configuration.AddJsonFile("environment/filedatabase.json", optional: false, reloadOnChange: true); var fileDatabasePath = CredentialTools.ResolvePathOrThrow("filedatabase", "environment/filedatabase.json");
builder.Configuration.AddJsonFile(fileDatabasePath, optional: false, reloadOnChange: false);
var fileDatabaseSettings = builder.Configuration.GetSection(nameof(FileDatabaseSettings)).Get<FileDatabaseSettings>(); var fileDatabaseSettings = builder.Configuration.GetSection(nameof(FileDatabaseSettings)).Get<FileDatabaseSettings>();
if (fileDatabaseSettings is null) { throw new Exception("File database settings are not configured"); } if (fileDatabaseSettings is null) { throw new Exception("File database settings are not configured"); }
+15 -5
View File
@@ -5,6 +5,7 @@ using DeepDrftWeb;
using MudBlazor.Services; using MudBlazor.Services;
using DeepDrftWeb.Components; using DeepDrftWeb.Components;
using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.HttpOverrides;
using NetBlocks.Utilities.Environment;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
@@ -13,11 +14,20 @@ builder.Services.AddMudServices();
builder.Services.AddCmsServices(); builder.Services.AddCmsServices();
// CMS → DeepDrftContent calls require the DeepDrftContent ApiKey. Loaded from a // Required credential files — must exist before the app will start.
// gitignored environment file, same shape as DeepDrftContent/environment/apikey.json. // In dev: create the three files under DeepDrftWeb/environment/ (gitignored).
// Optional so the file's absence in non-CMS dev does not fail boot; missing key is // In prod: systemd CREDENTIALS_DIRECTORY points to encrypted credential blobs.
// surfaced when Startup.ConfigureDomainServices binds the CMS HttpClient. // - environment/apikey.json: { "DeepDrftContent": { "ApiKey": "..." } }
builder.Configuration.AddJsonFile("environment/apikey.json", optional: true, reloadOnChange: true); // - environment/connections.json: { "ConnectionStrings": { "DefaultConnection": "...", "Auth": "..." } }
// - environment/authblocks.json: { "AuthBlocks": { "Jwt": {...}, "Email": {...}, "Admin": {...} } }
var apiKeyPath = CredentialTools.ResolvePathOrThrow("apikey", "environment/apikey.json");
builder.Configuration.AddJsonFile(apiKeyPath, optional: false, reloadOnChange: false);
var connectionsPath = CredentialTools.ResolvePathOrThrow("connections", "environment/connections.json");
builder.Configuration.AddJsonFile(connectionsPath, optional: false, reloadOnChange: false);
var authBlocksPath = CredentialTools.ResolvePathOrThrow("authblocks", "environment/authblocks.json");
builder.Configuration.AddJsonFile(authBlocksPath, optional: false, reloadOnChange: false);
var baseUrl = builder.GetKestrelUrl(); var baseUrl = builder.GetKestrelUrl();
var contentApiUrl = builder.Configuration["ApiUrls:ContentApi"] ?? throw new Exception("Content API URL is not configured"); var contentApiUrl = builder.Configuration["ApiUrls:ContentApi"] ?? throw new Exception("Content API URL is not configured");
-6
View File
@@ -6,15 +6,9 @@
} }
}, },
"AllowedHosts": "*", "AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "Host=localhost;Port=5433;Database=postgres;Username=postgres;Password=REPLACE_IN_ENV"
},
"ApiUrls": { "ApiUrls": {
"ContentApi": "http://localhost:12777/" "ContentApi": "http://localhost:12777/"
}, },
"DeepDrftContent": {
"ApiKey": "REPLACE_IN_ENV"
},
"ForwardedHeaders": { "ForwardedHeaders": {
"DisableHttpsRedirection": "true" "DisableHttpsRedirection": "true"
} }