46 lines
2.0 KiB
C#
46 lines
2.0 KiB
C#
using System.Security.Claims;
|
|
using Microsoft.AspNetCore.DataProtection;
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
using Microsoft.Extensions.FileProviders;
|
|
using ScadaBridgeUiCanary.Components;
|
|
using ZB.MOM.WW.ScadaBridge.CentralUI.Components.Shared;
|
|
using ZB.MOM.WW.Theme;
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
builder.WebHost.UseStaticWebAssets();
|
|
builder.Services.AddRazorComponents().AddInteractiveServerComponents();
|
|
builder.Services.AddDataProtection().UseEphemeralDataProtectionProvider();
|
|
builder.Services.AddAuthorizationCore();
|
|
builder.Services.AddCascadingAuthenticationState();
|
|
builder.Services.AddScoped<AuthenticationStateProvider, LocalAnonymousState>();
|
|
builder.Services.AddScoped<IDialogService, DialogService>();
|
|
var app = builder.Build();
|
|
app.UseStaticFiles(new StaticFileOptions
|
|
{
|
|
FileProvider = new PhysicalFileProvider(Path.Combine(
|
|
builder.Configuration["Canary:ScadaBridgeRoot"] ?? "/Users/dohertj2/Desktop/ScadaBridge",
|
|
"src/ZB.MOM.WW.ScadaBridge.Host/wwwroot"))
|
|
});
|
|
app.UseStaticFiles();
|
|
app.UseAntiforgery();
|
|
app.MapGet("/canary-provenance", () => new
|
|
{
|
|
purpose = "Disposable local component canary; not the complete ScadaBridge application",
|
|
themeAssembly = typeof(ThemeShell).Assembly.GetName().Version?.ToString(),
|
|
centralUiAssembly = typeof(DialogHost).Assembly.GetName().Version?.ToString(),
|
|
data = "Synthetic local only; no SQL, Akka, LDAP or fleet services registered",
|
|
source = "Authorized ScadaBridge checkout via project reference"
|
|
});
|
|
app.MapGet("/auth/ping", () => Results.Ok());
|
|
app.MapPost("/auth/activity", () => Results.NoContent());
|
|
app.MapPost("/auth/login", () => Results.StatusCode(405));
|
|
app.MapPost("/auth/logout", () => Results.StatusCode(405));
|
|
app.MapRazorComponents<App>().AddInteractiveServerRenderMode();
|
|
app.Run();
|
|
|
|
internal sealed class LocalAnonymousState : AuthenticationStateProvider
|
|
{
|
|
public override Task<AuthenticationState> GetAuthenticationStateAsync() =>
|
|
Task.FromResult(new AuthenticationState(new ClaimsPrincipal(new ClaimsIdentity())));
|
|
}
|