Files
Flypaper/src/Flypaper.Web/Program.cs
T
TomandClaude Sonnet 5.5 b559f83550
Build and deploy / build (push) Successful in 1m29s
Release / image (push) Successful in 1m53s
Build and deploy / deploy (push) Successful in 30s
Release / release (push) Successful in 6s
Record request headers and bodies and show them per catch
Headers and the first 8 KB of the body are stored unmasked for 30 days,
read alongside the response so the trap answers as before. MCP get_request
and the expanded catch row show them. Changelog prepared for 0.10.0.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-26 21:47:28 +01:00

86 lines
2.8 KiB
C#

using Flypaper.Core;
using Flypaper.GeoIp;
using Flypaper.Http;
using Flypaper.Storage;
using Flypaper.Web;
using Flypaper.Web.Auth;
using Flypaper.Web.Components;
using Flypaper.Web.Explanations;
using Flypaper.Web.Health;
using Flypaper.Web.Mcp;
using Flypaper.Web.Requests;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.DataProtection;
var builder = WebApplication.CreateBuilder(args);
var ports = builder.Configuration.GetSection(PortOptions.SectionName).Get<PortOptions>() ?? new PortOptions();
builder.WebHost.ConfigureKestrel(options =>
{
options.AddServerHeader = false;
options.ListenAnyIP(ports.Trap);
options.ListenAnyIP(ports.Dashboard);
});
builder.AddFlypaperStorage();
builder.Services.AddRazorComponents();
builder.Services.AddFlypaperCore(builder.Configuration);
builder.Services.AddFlypaperHttp(builder.Configuration);
builder.Services.AddFlypaperGeoIp(builder.Configuration);
var dataProtection = builder.Services.AddDataProtection().SetApplicationName("Flypaper");
if (builder.Configuration["Flypaper:DataProtection:KeysPath"] is { Length: > 0 } keysPath)
{
dataProtection.PersistKeysToFileSystem(new DirectoryInfo(keysPath));
}
builder.Services.AddFlypaperMcp(builder.Configuration);
builder.Services.Configure<AdminOptions>(builder.Configuration.GetSection(AdminOptions.SectionName));
builder.Services.AddSingleton<AdminAuthenticator>();
builder.Services
.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options =>
{
options.LoginPath = "/login";
options.AccessDeniedPath = "/login";
options.Cookie.Name = "flypaper.auth";
options.Cookie.HttpOnly = true;
options.Cookie.SameSite = SameSiteMode.Strict;
options.ExpireTimeSpan = TimeSpan.FromHours(8);
options.SlidingExpiration = true;
});
builder.Services.AddAuthorizationBuilder()
.SetFallbackPolicy(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build());
var app = builder.Build();
app.Logger.LogInformation("Flypaper {Version} starting", AppVersion.Current);
FlypaperHttpExtensions.WarnAboutRemovedSettings(app.Configuration, app.Logger);
await app.Services.MigrateFlypaperDatabaseAsync();
app.UseFlypaper();
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error", createScopeForErrors: true);
}
app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true);
app.UseAuthentication();
app.UseAuthorization();
app.UseAntiforgery();
app.MapStaticAssets().AllowAnonymous();
app.MapAuthEndpoints();
app.MapHealthEndpoint();
app.MapFlypaperMcp();
app.MapExplanationEndpoints();
app.MapRequestEndpoints();
app.MapRazorComponents<App>();
await app.RunAsync();
public partial class Program;