Fix Wave 2 review: PG18 volume path, null guards, NotAuthorized redirect, drop docker-compose, port 5433 connection strings

This commit is contained in:
Daniel Harvey
2026-05-18 09:38:25 -04:00
parent ee7dc8409e
commit d1f3cbd89b
8 changed files with 35 additions and 33 deletions
+1
View File
@@ -15,6 +15,7 @@ Startup.ConfigureContentServices(builder.Services, contentApiUrl);
Startup.ConfigureDomainServices(builder.Services);
// AuthBlocks WASM: auth state deserialization bridge (prerender → WASM handoff).
// Registers AddAuthorizationCore, AddCascadingAuthenticationState, AddAuthenticationStateDeserialization.
AuthBlocksWeb.Client.Startup.ConfigureServices(builder.Services);
var app = builder.Build();
+10 -2
View File
@@ -1,5 +1,13 @@
<Router AppAssembly="typeof(_Imports).Assembly">
@inject NavigationManager NavigationManager
<Router AppAssembly="typeof(_Imports).Assembly">
<Found Context="routeData">
<AuthorizeRouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)" />
<AuthorizeRouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)">
<NotAuthorized>
@{
NavigationManager.NavigateTo($"account/login?returnUrl={Uri.EscapeDataString(NavigationManager.Uri)}", forceLoad: true);
}
</NotAuthorized>
</AuthorizeRouteView>
</Found>
</Router>
@@ -47,7 +47,6 @@ public class TrackConfiguration : IEntityTypeConfiguration<TrackEntity>
.HasMaxLength(500);
builder.Property(x => x.CreatedByUserId)
.HasColumnName("created_by_user_id")
.IsRequired(false);
.HasColumnName("created_by_user_id");
}
}
@@ -10,9 +10,9 @@ public class DeepDrftContextFactory : IDesignTimeDbContextFactory<DeepDrftContex
// For 'dotnet ef' commands, set ConnectionStrings__DefaultConnection in your environment when
// you need to actually hit the database (e.g. `dotnet ef database update`). For model-only
// operations like `migrations add`, the placeholder below is sufficient — EF never connects.
// Example: export ConnectionStrings__DefaultConnection="Host=localhost;Database=deepdrft_dev;Username=postgres;Password=yourpassword"
// Example: export ConnectionStrings__DefaultConnection="Host=localhost;Port=5433;Database=postgres;Username=postgres;Password=yourpassword"
var connectionString = Environment.GetEnvironmentVariable("ConnectionStrings__DefaultConnection")
?? "Host=localhost;Database=deepdrft_dev;Username=postgres;Password=placeholder";
?? "Host=localhost;Port=5433;Database=postgres;Username=postgres;Password=placeholder";
var optionsBuilder = new DbContextOptionsBuilder<DeepDrftContext>();
optionsBuilder.UseNpgsql(connectionString);
+19 -12
View File
@@ -13,9 +13,6 @@ builder.Services.AddMudServices();
builder.Services.AddCmsServices();
// Add AudioInteropService for both server and client rendering
// builder.Services.AddScoped<AudioInteropService>();
var baseUrl = builder.GetKestrelUrl();
var contentApiUrl = builder.Configuration["ApiUrls:ContentApi"] ?? throw new Exception("Content API URL is not configured");
@@ -23,26 +20,36 @@ var contentApiUrl = builder.Configuration["ApiUrls:ContentApi"] ?? throw new Exc
// Auth schema runs in its own database (separate from DefaultConnection by design).
builder.Services.AddAuthBlocks(options =>
{
options.ConnectionString = builder.Configuration.GetConnectionString("Auth")!;
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"]!;
options.JwtSettings.Issuer = builder.Configuration["AuthBlocks:Jwt:Issuer"]!;
options.JwtSettings.Audience = builder.Configuration["AuthBlocks:Jwt:Audience"]!;
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"]!;
options.EmailConnection.Token = builder.Configuration["AuthBlocks:Email:Token"]!;
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"]!,
Email = builder.Configuration["AuthBlocks:Admin:Email"]!,
Password = builder.Configuration["AuthBlocks:Admin:Password"]!
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: Blazor JWT client services (auth API is mounted on this same host via MapAuthBlocks).
// AuthBlocksWeb.Startup.ConfigureAuthServices registers AddCascadingAuthenticationState server-side.
AuthBlocksWeb.Startup.ConfigureAuthServices(builder.Services, baseUrl);
DeepDrftWeb.Client.Startup.ConfigureApiHttpClient(builder.Services, baseUrl);
+1 -1
View File
@@ -7,7 +7,7 @@
},
"AllowedHosts": "*",
"ConnectionStrings": {
"DefaultConnection": "Host=localhost;Database=deepdrft_dev;Username=postgres;Password=REPLACE_IN_ENV"
"DefaultConnection": "Host=localhost;Port=5433;Database=postgres;Username=postgres;Password=REPLACE_IN_ENV"
},
"ApiUrls": {
"ContentApi": "http://localhost:12777/"
+1
View File
@@ -2,6 +2,7 @@
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<!-- Machine-specific local feed — update path if not at C:\Development\AuthBlocks\nupkgs\ -->
<add key="AuthBlocks-local" value="C:\Development\AuthBlocks\nupkgs\" />
</packageSources>
</configuration>
-14
View File
@@ -1,14 +0,0 @@
services:
postgres:
image: postgres:18
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: deepdrft_dev
ports:
- "5432:5432"
volumes:
- deepdrft_postgres:/var/lib/postgresql/data
volumes:
deepdrft_postgres: