Merge branch 'split-phase1-manager' into dev

This commit is contained in:
Daniel Harvey
2026-05-19 15:29:41 -04:00
10 changed files with 322 additions and 0 deletions
+14
View File
@@ -20,6 +20,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeepDrftContent.Data", "Dee
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeepDrftCms", "DeepDrftCms\DeepDrftCms.csproj", "{81F1D47F-F892-45FB-9E35-D7775805FFD3}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeepDrftCms", "DeepDrftCms\DeepDrftCms.csproj", "{81F1D47F-F892-45FB-9E35-D7775805FFD3}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeepDrftManager", "DeepDrftManager\DeepDrftManager.csproj", "{E50071B2-A59F-4FB7-A435-5D966C538DDD}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@@ -150,6 +152,18 @@ Global
{81F1D47F-F892-45FB-9E35-D7775805FFD3}.Release|x64.Build.0 = Release|Any CPU {81F1D47F-F892-45FB-9E35-D7775805FFD3}.Release|x64.Build.0 = Release|Any CPU
{81F1D47F-F892-45FB-9E35-D7775805FFD3}.Release|x86.ActiveCfg = Release|Any CPU {81F1D47F-F892-45FB-9E35-D7775805FFD3}.Release|x86.ActiveCfg = Release|Any CPU
{81F1D47F-F892-45FB-9E35-D7775805FFD3}.Release|x86.Build.0 = Release|Any CPU {81F1D47F-F892-45FB-9E35-D7775805FFD3}.Release|x86.Build.0 = Release|Any CPU
{E50071B2-A59F-4FB7-A435-5D966C538DDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E50071B2-A59F-4FB7-A435-5D966C538DDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E50071B2-A59F-4FB7-A435-5D966C538DDD}.Debug|x64.ActiveCfg = Debug|Any CPU
{E50071B2-A59F-4FB7-A435-5D966C538DDD}.Debug|x64.Build.0 = Debug|Any CPU
{E50071B2-A59F-4FB7-A435-5D966C538DDD}.Debug|x86.ActiveCfg = Debug|Any CPU
{E50071B2-A59F-4FB7-A435-5D966C538DDD}.Debug|x86.Build.0 = Debug|Any CPU
{E50071B2-A59F-4FB7-A435-5D966C538DDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E50071B2-A59F-4FB7-A435-5D966C538DDD}.Release|Any CPU.Build.0 = Release|Any CPU
{E50071B2-A59F-4FB7-A435-5D966C538DDD}.Release|x64.ActiveCfg = Release|Any CPU
{E50071B2-A59F-4FB7-A435-5D966C538DDD}.Release|x64.Build.0 = Release|Any CPU
{E50071B2-A59F-4FB7-A435-5D966C538DDD}.Release|x86.ActiveCfg = Release|Any CPU
{E50071B2-A59F-4FB7-A435-5D966C538DDD}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
+22
View File
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="/" />
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,300;0,400;0,600;1,300;1,400&family=Geist+Mono:wght@300;400;500&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;1,9..40,300&display=swap" rel="stylesheet">
<link href=@Assets["_content/MudBlazor/MudBlazor.min.css"] rel="stylesheet" />
<ImportMap />
<link rel="icon" type="image/ico" href="deepdrft-logo.ico" />
<HeadOutlet />
</head>
<body>
<Routes />
<script src="_framework/blazor.web.js"></script>
<script src=@Assets["_content/MudBlazor/MudBlazor.min.js"]></script>
</body>
</html>
+19
View File
@@ -0,0 +1,19 @@
<Router AppAssembly="typeof(App).Assembly"
AdditionalAssemblies="new[] { typeof(DeepDrftCms._Imports).Assembly, typeof(AuthBlocksWeb._Imports).Assembly }">
<Found Context="routeData">
<AuthorizeRouteView RouteData="routeData">
<NotAuthorized>
@{
NavigationManager.NavigateTo($"account/login?returnUrl={Uri.EscapeDataString(NavigationManager.Uri)}", forceLoad: true);
}
</NotAuthorized>
</AuthorizeRouteView>
<FocusOnNavigate RouteData="routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>Not found</PageTitle>
<p role="alert">Sorry, there's nothing at this address.</p>
</NotFound>
</Router>
@inject NavigationManager NavigationManager
@@ -0,0 +1,8 @@
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.Authorization
@using Microsoft.AspNetCore.Components.Routing
@using Microsoft.AspNetCore.Components.Web
@using static Microsoft.AspNetCore.Components.Web.RenderMode
@using MudBlazor
@using DeepDrftManager
@using DeepDrftManager.Components
+25
View File
@@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<!-- EF Core kept in sync with DeepDrftData / DeepDrftWeb so the same DbContext registration compiles. -->
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.7" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.1" />
<PackageReference Include="MudBlazor" Version="8.15.0" />
<PackageReference Include="Cerebellum.AuthBlocks" Version="10.3.32" />
<PackageReference Include="Cerebellum.AuthBlocks.Web" Version="10.3.32" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DeepDrftCms\DeepDrftCms.csproj" />
<ProjectReference Include="..\DeepDrftData\DeepDrftData.csproj" />
<ProjectReference Include="..\DeepDrftModels\DeepDrftModels.csproj" />
</ItemGroup>
</Project>
+189
View File
@@ -0,0 +1,189 @@
using AuthBlocksLib;
using AuthBlocksLib.Options;
using DeepDrftCms;
using DeepDrftData;
using DeepDrftData.Data;
using DeepDrftData.Repositories;
using DeepDrftManager.Components;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.EntityFrameworkCore;
using MudBlazor.Services;
using NetBlocks.Utilities.Environment;
var builder = WebApplication.CreateBuilder(args);
// Required credential files — must exist before the app will start.
// Production secrets stay gitignored; the *.example.json templates at the project root show the shape.
// - environment/apikey.json: { "DeepDrftContent": { "ApiKey": "..." } }
// - environment/connections.json: { "ConnectionStrings": { "DefaultConnection": "...", "Auth": "..." } }
// - environment/authblocks.json: { "AuthBlocks": { "Jwt": {...}, "Email": {...}, "Admin": {...} } }
// Content API key — not consumed by this host in Phase 1. Required by the CredentialTools
// pattern (the file must exist); will be used by CmsUploadController when it migrates here.
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);
// MudBlazor.
builder.Services.AddMudServices();
// CMS-specific services (currently a no-op placeholder; reserved for future RCL additions).
builder.Services.AddCmsServices();
// SQL metadata domain — DbContext + repository + manager. The CMS pages inject ITrackService
// and resolve the same scoped TrackManager instance, so the DTO and entity surfaces share state.
builder.Services.AddDbContext<DeepDrftContext>(options =>
options.UseNpgsql(builder.Configuration.GetConnectionString("DefaultConnection")));
builder.Services
.AddScoped<TrackRepository>()
.AddScoped<TrackManager>()
.AddScoped<ITrackService>(sp => sp.GetRequiredService<TrackManager>());
// AuthBlocks: JWT Bearer auth, Identity, EF schema, admin seeding.
// Auth schema runs in its own database (separate from DefaultConnection by design).
builder.Services.AddAuthBlocks(options =>
{
options.ConnectionString = builder.Configuration.GetConnectionString("Auth")
?? throw new InvalidOperationException("ConnectionStrings:Auth is required");
options.ApplicationName = "DeepDrft";
options.SupportEmail = builder.Configuration["AuthBlocks:SupportEmail"] ?? "admin@deepdrft.com";
options.JwtSettings.Secret = builder.Configuration["AuthBlocks:Jwt:Secret"]
?? throw new InvalidOperationException("AuthBlocks:Jwt:Secret is required");
options.JwtSettings.Issuer = builder.Configuration["AuthBlocks:Jwt:Issuer"]
?? throw new InvalidOperationException("AuthBlocks:Jwt:Issuer is required");
options.JwtSettings.Audience = builder.Configuration["AuthBlocks:Jwt:Audience"]
?? throw new InvalidOperationException("AuthBlocks:Jwt:Audience is required");
options.EmailConnection.Host = builder.Configuration["AuthBlocks:Email:Host"]
?? throw new InvalidOperationException("AuthBlocks:Email:Host is required");
options.EmailConnection.Token = builder.Configuration["AuthBlocks:Email:Token"]
?? throw new InvalidOperationException("AuthBlocks:Email:Token is required");
options.AdminUserSettings = new AdminUserSettings
{
UserName = builder.Configuration["AuthBlocks:Admin:UserName"]
?? throw new InvalidOperationException("AuthBlocks:Admin:UserName is required"),
Email = builder.Configuration["AuthBlocks:Admin:Email"]
?? throw new InvalidOperationException("AuthBlocks:Admin:Email is required"),
Password = builder.Configuration["AuthBlocks:Admin:Password"]
?? throw new InvalidOperationException("AuthBlocks:Admin:Password is required")
};
});
// AuthBlocksWeb: server-side cascading auth state plus the JWT client services used by the
// /account/login + /account/logout Razor pages that ship in the AuthBlocksWeb RCL.
var baseUrl = GetKestrelUrl(builder);
AuthBlocksWeb.Startup.ConfigureAuthServices(builder.Services, baseUrl);
// Named HttpClient used by CMS pages for delete/upload calls.
// Phase 1: points at DeepDrftWeb (https://localhost:5001) where the CMS mutation controllers
// (CmsUploadController, CmsEditController, CmsDeleteController) currently live.
// When those controllers migrate to DeepDrftManager, update ApiUrls:ApiHost to this host's URL.
var apiHostUrl = builder.Configuration["ApiUrls:ApiHost"]
?? throw new InvalidOperationException("ApiUrls:ApiHost is required");
builder.Services.AddHttpClient("DeepDrft.API", client =>
{
client.BaseAddress = new Uri(apiHostUrl);
});
// Reverse-proxy support (nginx in production).
builder.Services.Configure<ForwardedHeadersOptions>(options =>
{
options.ForwardedHeaders =
ForwardedHeaders.XForwardedFor |
ForwardedHeaders.XForwardedProto |
ForwardedHeaders.XForwardedHost;
options.KnownNetworks.Clear();
options.KnownProxies.Clear();
});
// Controllers: no-op until CMS mutation controllers migrate from DeepDrftWeb, but registered
// now so they are discovered automatically when they arrive. Matches DeepDrftWeb precedent.
builder.Services.AddControllers();
// InteractiveServer only — no WASM render mode on the CMS host.
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
// SignalR tuning for InteractiveServer circuits. Long-running CMS operations (upload progress,
// large table loads) benefit from tighter keepalive and detailed errors in dev.
builder.Services.AddSignalR(options =>
{
if (builder.Environment.IsDevelopment())
{
options.EnableDetailedErrors = true;
options.KeepAliveInterval = TimeSpan.FromSeconds(10);
options.ClientTimeoutInterval = TimeSpan.FromSeconds(30);
}
});
var app = builder.Build();
// Apply AuthBlocks EF migrations, seed system roles, seed admin user on first boot.
await app.Services.UseAuthBlocksStartupAsync();
app.UseForwardedHeaders();
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
app.UseHsts();
var disableHttpsRedirection = app.Configuration.GetValue<bool>("ForwardedHeaders:DisableHttpsRedirection");
if (!disableHttpsRedirection)
{
app.UseHttpsRedirection();
}
}
app.UseAuthentication();
app.UseAuthorization();
app.UseAntiforgery();
app.MapStaticAssets();
// Mount AuthBlocks API surface (/api/auth/*, /api/users/*, etc.) and the AuthBlocksWeb
// Razor pages (/account/login, /account/logout).
app.MapAuthBlocks();
// No-op today; picks up CMS mutation controllers when they migrate from DeepDrftWeb.
app.MapControllers();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode()
.AddAdditionalAssemblies(
typeof(DeepDrftCms._Imports).Assembly,
typeof(AuthBlocksWeb._Imports).Assembly);
app.Run();
// Local helper — mirrors DeepDrftWeb.Startup.GetKestrelUrl. Kept inline because this host's
// only consumer is right here; promoting to a shared library would be premature.
static string GetKestrelUrl(WebApplicationBuilder builder)
{
var urls = builder.Configuration["ASPNETCORE_URLS"]
?? builder.Configuration["urls"];
if (!string.IsNullOrEmpty(urls))
{
return urls.Split(';')[0].Trim();
}
var firstEndpoint = builder.Configuration.GetSection("Kestrel:Endpoints").GetChildren().FirstOrDefault();
var endpointUrl = firstEndpoint?["Url"];
if (!string.IsNullOrEmpty(endpointUrl))
{
return endpointUrl;
}
return builder.Environment.IsDevelopment()
? "https://localhost:5004"
: "http://localhost:5000";
}
+5
View File
@@ -0,0 +1,5 @@
{
"DeepDrftContent": {
"ApiKey": "your-secret-api-key-here"
}
}
+15
View File
@@ -0,0 +1,15 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"ApiUrls": {
"ApiHost": "https://localhost:5001"
},
"ForwardedHeaders": {
"DisableHttpsRedirection": false
}
}
+19
View File
@@ -0,0 +1,19 @@
{
"AuthBlocks": {
"SupportEmail": "admin@deepdrft.com",
"Jwt": {
"Secret": "your-jwt-secret-here",
"Issuer": "https://deepdrft.com",
"Audience": "deepdrft-users"
},
"Email": {
"Host": "smtp.your-provider.com",
"Token": "your-email-token-here"
},
"Admin": {
"UserName": "admin",
"Email": "admin@deepdrft.com",
"Password": "your-admin-password-here"
}
}
}
+6
View File
@@ -0,0 +1,6 @@
{
"ConnectionStrings": {
"DefaultConnection": "Host=localhost;Port=5433;Database=deepdrft;Username=postgres;Password=your-password-here",
"Auth": "Host=localhost;Port=5433;Database=deepdrft_auth;Username=postgres;Password=your-password-here"
}
}