Separate dashboard port, first-run password setup and default trusted proxies
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
a34ff96490
commit
c22d452720
25 files changed
+654
-109
No files matched your search
@@ -14,9 +14,12 @@ namespace Flypaper.Http;
|
||||
|
||||
public static class FlypaperHttpExtensions
|
||||
{
|
||||
private static readonly string[] DefaultTrustedProxies = ["10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16", "fc00::/7"];
|
||||
|
||||
public static IServiceCollection AddFlypaperHttp(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.Configure<HttpTrapOptions>(configuration.GetSection(HttpTrapOptions.SectionName));
|
||||
services.Configure<PortOptions>(configuration.GetSection(PortOptions.SectionName));
|
||||
services.PostConfigure<HttpTrapOptions>(options =>
|
||||
{
|
||||
if (options.TrapPathsOverride is not null)
|
||||
@@ -33,7 +36,9 @@ public static class FlypaperHttpExtensions
|
||||
{
|
||||
forwarded.ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
|
||||
forwarded.ForwardLimit = 1;
|
||||
foreach (var proxy in trap.Value.TrustedProxies)
|
||||
var configured = trap.Value.TrustedProxies.Where(proxy => !string.IsNullOrWhiteSpace(proxy)).ToArray();
|
||||
var proxies = configured.Length > 0 ? configured : DefaultTrustedProxies;
|
||||
foreach (var proxy in proxies)
|
||||
{
|
||||
forwarded.KnownIPNetworks.Add(System.Net.IPNetwork.Parse(proxy.Contains('/') ? proxy : $"{proxy}/{HostBits(proxy)}"));
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using Flypaper.Http.Matching;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core.Features;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Flypaper.Http.Middleware;
|
||||
|
||||
@@ -14,17 +15,24 @@ internal sealed class FlypaperMiddleware(
|
||||
RequestDelegate next,
|
||||
TrapMatcher matcher,
|
||||
TrapRunner runner,
|
||||
IOptions<PortOptions> ports,
|
||||
TimeProvider timeProvider)
|
||||
{
|
||||
public async Task InvokeAsync(HttpContext context)
|
||||
{
|
||||
var request = context.Request;
|
||||
if (IsInternalHealthProbe(context) || matcher.Match(request.Host.Host, request.Path.Value) == TrapMatch.None)
|
||||
if (context.Connection.LocalPort == ports.Value.Dashboard || IsInternalHealthProbe(context))
|
||||
{
|
||||
await next(context);
|
||||
return;
|
||||
}
|
||||
|
||||
var request = context.Request;
|
||||
if (matcher.Match(request.Host.Host, request.Path.Value) == TrapMatch.None)
|
||||
{
|
||||
context.Response.StatusCode = StatusCodes.Status404NotFound;
|
||||
return;
|
||||
}
|
||||
|
||||
var session = new TrapSession(
|
||||
Guid.NewGuid(),
|
||||
TrapProtocol.Http,
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Flypaper.Http;
|
||||
|
||||
public sealed class PortOptions
|
||||
{
|
||||
public const string SectionName = "Flypaper:Ports";
|
||||
|
||||
public int Trap { get; set; } = 8080;
|
||||
|
||||
public int Dashboard { get; set; } = 8081;
|
||||
}
|
||||
@@ -20,6 +20,7 @@ public static class FlypaperStorageExtensions
|
||||
builder.Configuration.Add(source);
|
||||
builder.Services.AddSingleton(source);
|
||||
builder.Services.AddSingleton<RuntimeSettingsStore>();
|
||||
builder.Services.AddSingleton<AdminCredentialStore>();
|
||||
builder.Services.Configure<RetentionOptions>(builder.Configuration.GetSection(RetentionOptions.SectionName));
|
||||
builder.Services.AddFlypaperStorage(connectionString);
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
using Flypaper.Storage.Entities;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Flypaper.Storage.Settings;
|
||||
|
||||
public sealed class AdminCredentialStore(IDbContextFactory<FlypaperDbContext> dbContextFactory)
|
||||
{
|
||||
private const string PasswordHashKey = "Flypaper:Admin:PasswordHash";
|
||||
|
||||
public async Task<string?> GetPasswordHashAsync(CancellationToken ct = default)
|
||||
{
|
||||
await using var db = await dbContextFactory.CreateDbContextAsync(ct);
|
||||
return await db.Settings.Where(s => s.Key == PasswordHashKey).Select(s => s.Value).SingleOrDefaultAsync(ct);
|
||||
}
|
||||
|
||||
public async Task<bool> TryCreatePasswordHashAsync(string hash, CancellationToken ct = default)
|
||||
{
|
||||
await using var db = await dbContextFactory.CreateDbContextAsync(ct);
|
||||
db.Settings.Add(new SettingEntity { Key = PasswordHashKey, Value = hash });
|
||||
try
|
||||
{
|
||||
await db.SaveChangesAsync(ct);
|
||||
return true;
|
||||
}
|
||||
catch (DbUpdateException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task UpdatePasswordHashAsync(string hash, CancellationToken ct = default)
|
||||
{
|
||||
await using var db = await dbContextFactory.CreateDbContextAsync(ct);
|
||||
var updated = await db.Settings
|
||||
.Where(s => s.Key == PasswordHashKey)
|
||||
.ExecuteUpdateAsync(setters => setters.SetProperty(s => s.Value, hash), ct);
|
||||
if (updated == 0)
|
||||
{
|
||||
db.Settings.Add(new SettingEntity { Key = PasswordHashKey, Value = hash });
|
||||
await db.SaveChangesAsync(ct);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,11 +10,13 @@ public sealed partial class RuntimeSettingsStore(
|
||||
DbConfigurationSource source,
|
||||
ILogger<RuntimeSettingsStore> logger)
|
||||
{
|
||||
private static readonly string[] RuntimeKeys = SettingKeys.All.ToArray();
|
||||
|
||||
public async Task SaveAsync(RuntimeSettings settings, CancellationToken ct = default)
|
||||
{
|
||||
await using var db = await dbContextFactory.CreateDbContextAsync(ct);
|
||||
await using var transaction = await db.Database.BeginTransactionAsync(ct);
|
||||
await db.Settings.ExecuteDeleteAsync(ct);
|
||||
await RuntimeSettings(db).ExecuteDeleteAsync(ct);
|
||||
db.Settings.AddRange(settings.ToConfiguration().Select(pair => new SettingEntity { Key = pair.Key, Value = pair.Value }));
|
||||
await db.SaveChangesAsync(ct);
|
||||
await transaction.CommitAsync(ct);
|
||||
@@ -24,16 +26,19 @@ public sealed partial class RuntimeSettingsStore(
|
||||
public async Task ResetAsync(CancellationToken ct = default)
|
||||
{
|
||||
await using var db = await dbContextFactory.CreateDbContextAsync(ct);
|
||||
await db.Settings.ExecuteDeleteAsync(ct);
|
||||
await RuntimeSettings(db).ExecuteDeleteAsync(ct);
|
||||
Reload();
|
||||
}
|
||||
|
||||
public async Task<bool> HasOverridesAsync(CancellationToken ct = default)
|
||||
{
|
||||
await using var db = await dbContextFactory.CreateDbContextAsync(ct);
|
||||
return await db.Settings.AnyAsync(ct);
|
||||
return await RuntimeSettings(db).AnyAsync(ct);
|
||||
}
|
||||
|
||||
private static IQueryable<SettingEntity> RuntimeSettings(FlypaperDbContext db) =>
|
||||
db.Settings.Where(setting => RuntimeKeys.Contains(setting.Key));
|
||||
|
||||
private void Reload()
|
||||
{
|
||||
if (!source.TryReload())
|
||||
|
||||
@@ -1,22 +1,64 @@
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Flypaper.Storage.Settings;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Flypaper.Web.Auth;
|
||||
|
||||
public sealed class AdminAuthenticator(IOptions<AdminOptions> options)
|
||||
public sealed class AdminAuthenticator(IOptions<AdminOptions> options, AdminCredentialStore store)
|
||||
{
|
||||
public bool IsConfigured => !string.IsNullOrEmpty(options.Value.Password);
|
||||
public const int MinimumPasswordLength = 12;
|
||||
|
||||
public bool Verify(string? candidate)
|
||||
private static readonly PasswordHasher<AdminAccount> Hasher = new();
|
||||
private static readonly AdminAccount Account = new();
|
||||
|
||||
public bool UsesEnvironmentPassword => !string.IsNullOrEmpty(options.Value.Password);
|
||||
|
||||
public async Task<bool> IsConfiguredAsync(CancellationToken ct = default) =>
|
||||
UsesEnvironmentPassword || await store.GetPasswordHashAsync(ct) is not null;
|
||||
|
||||
public async Task<bool> VerifyAsync(string? candidate, CancellationToken ct = default)
|
||||
{
|
||||
if (!IsConfigured || string.IsNullOrEmpty(candidate))
|
||||
if (string.IsNullOrEmpty(candidate))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return CryptographicOperations.FixedTimeEquals(Hash(candidate), Hash(options.Value.Password!));
|
||||
if (UsesEnvironmentPassword)
|
||||
{
|
||||
return CryptographicOperations.FixedTimeEquals(Sha256(candidate), Sha256(options.Value.Password!));
|
||||
}
|
||||
|
||||
return await store.GetPasswordHashAsync(ct) is { } hash
|
||||
&& Hasher.VerifyHashedPassword(Account, hash, candidate) != PasswordVerificationResult.Failed;
|
||||
}
|
||||
|
||||
private static byte[] Hash(string value) => SHA256.HashData(Encoding.UTF8.GetBytes(value));
|
||||
public async Task<bool> TrySetInitialPasswordAsync(string password, CancellationToken ct = default) =>
|
||||
!UsesEnvironmentPassword && await store.TryCreatePasswordHashAsync(Hasher.HashPassword(Account, password), ct);
|
||||
|
||||
public async Task<bool> TryChangePasswordAsync(string currentPassword, string newPassword, CancellationToken ct = default)
|
||||
{
|
||||
if (UsesEnvironmentPassword || !await VerifyAsync(currentPassword, ct))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
await store.UpdatePasswordHashAsync(Hasher.HashPassword(Account, newPassword), ct);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static string? ValidateNewPassword(string? password, string? confirmation)
|
||||
{
|
||||
if (string.IsNullOrEmpty(password) || password.Length < MinimumPasswordLength)
|
||||
{
|
||||
return $"Mindestens {MinimumPasswordLength} Zeichen.";
|
||||
}
|
||||
|
||||
return password == confirmation ? null : "Die Passwörter stimmen nicht überein.";
|
||||
}
|
||||
|
||||
private static byte[] Sha256(string value) => SHA256.HashData(Encoding.UTF8.GetBytes(value));
|
||||
|
||||
public sealed class AdminAccount;
|
||||
}
|
||||
@@ -18,17 +18,41 @@ public static class AuthEndpoints
|
||||
{
|
||||
var target = IsLocalPath(returnUrl) ? returnUrl! : "/";
|
||||
|
||||
if (!admin.Verify(password))
|
||||
if (!await admin.VerifyAsync(password, context.RequestAborted))
|
||||
{
|
||||
await Task.Delay(750, context.RequestAborted);
|
||||
return Results.LocalRedirect($"/login?error=1&returnUrl={Uri.EscapeDataString(target)}");
|
||||
}
|
||||
|
||||
var identity = new ClaimsIdentity([new Claim(ClaimTypes.Name, "admin")], CookieAuthenticationDefaults.AuthenticationScheme);
|
||||
await context.SignInAsync(new ClaimsPrincipal(identity));
|
||||
await SignInAsync(context);
|
||||
return Results.LocalRedirect(target);
|
||||
}).AllowAnonymous();
|
||||
|
||||
app.MapPost("/auth/setup", async (
|
||||
HttpContext context,
|
||||
AdminAuthenticator admin,
|
||||
[FromForm] string? password,
|
||||
[FromForm] string? confirmation) =>
|
||||
{
|
||||
if (await admin.IsConfiguredAsync(context.RequestAborted))
|
||||
{
|
||||
return Results.LocalRedirect("/login");
|
||||
}
|
||||
|
||||
if (AdminAuthenticator.ValidateNewPassword(password, confirmation) is { } error)
|
||||
{
|
||||
return Results.LocalRedirect($"/setup?error={Uri.EscapeDataString(error)}");
|
||||
}
|
||||
|
||||
if (!await admin.TrySetInitialPasswordAsync(password!, context.RequestAborted))
|
||||
{
|
||||
return Results.LocalRedirect("/login");
|
||||
}
|
||||
|
||||
await SignInAsync(context);
|
||||
return Results.LocalRedirect("/");
|
||||
}).AllowAnonymous();
|
||||
|
||||
app.MapPost("/auth/logout", async (HttpContext context, IAntiforgery antiforgery) =>
|
||||
{
|
||||
if (!await antiforgery.IsRequestValidAsync(context))
|
||||
@@ -43,6 +67,12 @@ public static class AuthEndpoints
|
||||
return app;
|
||||
}
|
||||
|
||||
private static Task SignInAsync(HttpContext context)
|
||||
{
|
||||
var identity = new ClaimsIdentity([new Claim(ClaimTypes.Name, "admin")], CookieAuthenticationDefaults.AuthenticationScheme);
|
||||
return context.SignInAsync(new ClaimsPrincipal(identity));
|
||||
}
|
||||
|
||||
private static bool IsLocalPath(string? url) =>
|
||||
!string.IsNullOrEmpty(url) && url[0] == '/' && (url.Length == 1 || (url[1] != '/' && url[1] != '\\'));
|
||||
}
|
||||
@@ -3,35 +3,34 @@
|
||||
@attribute [AllowAnonymous]
|
||||
@using Flypaper.Web.Auth
|
||||
@inject AdminAuthenticator Admin
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
<PageTitle>Flypaper · Anmelden</PageTitle>
|
||||
|
||||
<h1 class="login-title">Flypaper</h1>
|
||||
|
||||
@if (!Admin.IsConfigured)
|
||||
{
|
||||
<div class="banner bad">
|
||||
<strong>Zugang gesperrt.</strong>
|
||||
Es ist kein Admin-Passwort gesetzt. Setze die Umgebungsvariable <code>Flypaper__Admin__Password</code> und starte den Container neu.
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<form method="post" action="/auth/login" class="card form">
|
||||
<AntiforgeryToken />
|
||||
<input type="hidden" name="returnUrl" value="@ReturnUrl" />
|
||||
<label for="password">Passwort</label>
|
||||
<input id="password" name="password" type="password" autocomplete="current-password" autofocus required />
|
||||
@if (Error is not null)
|
||||
{
|
||||
<p class="error">Passwort falsch.</p>
|
||||
}
|
||||
<button type="submit">Anmelden</button>
|
||||
</form>
|
||||
}
|
||||
<form method="post" action="/auth/login" class="card form">
|
||||
<AntiforgeryToken />
|
||||
<input type="hidden" name="returnUrl" value="@ReturnUrl" />
|
||||
<label for="password">Passwort</label>
|
||||
<input id="password" name="password" type="password" autocomplete="current-password" autofocus required />
|
||||
@if (Error is not null)
|
||||
{
|
||||
<p class="error">Passwort falsch.</p>
|
||||
}
|
||||
<button type="submit">Anmelden</button>
|
||||
</form>
|
||||
|
||||
@code {
|
||||
[SupplyParameterFromQuery(Name = "error")] private string? Error { get; set; }
|
||||
|
||||
[SupplyParameterFromQuery(Name = "returnUrl")] private string? ReturnUrl { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (!await Admin.IsConfiguredAsync())
|
||||
{
|
||||
Navigation.NavigateTo("/setup");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Flypaper.Web.Components.Pages.Settings;
|
||||
|
||||
public sealed class PasswordModel
|
||||
{
|
||||
public string? Current { get; set; }
|
||||
|
||||
public string? New { get; set; }
|
||||
|
||||
public string? Confirmation { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
@using Flypaper.Web.Auth
|
||||
@inject AdminAuthenticator Admin
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
<section class="card form">
|
||||
<h2>Admin-Passwort</h2>
|
||||
|
||||
@if (Changed == "changed")
|
||||
{
|
||||
<div class="banner ok">Passwort geändert.</div>
|
||||
}
|
||||
|
||||
@if (Admin.UsesEnvironmentPassword)
|
||||
{
|
||||
<p class="muted">Das Passwort kommt aus der Umgebungsvariable <code>Flypaper__Admin__Password</code> und lässt sich nur dort ändern.</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<EditForm Model="Model" FormName="password" OnSubmit="ChangeAsync" action="/settings" class="form">
|
||||
<label for="current-password">Aktuelles Passwort</label>
|
||||
<InputText id="current-password" type="password" autocomplete="current-password" @bind-Value="Model!.Current" />
|
||||
<FieldError Errors="_errors" Field="@nameof(PasswordModel.Current)" />
|
||||
|
||||
<label for="new-password">Neues Passwort <span class="muted">(mindestens @AdminAuthenticator.MinimumPasswordLength Zeichen)</span></label>
|
||||
<InputText id="new-password" type="password" autocomplete="new-password" @bind-Value="Model!.New" />
|
||||
|
||||
<label for="confirm-password">Neues Passwort wiederholen</label>
|
||||
<InputText id="confirm-password" type="password" autocomplete="new-password" @bind-Value="Model!.Confirmation" />
|
||||
<FieldError Errors="_errors" Field="@nameof(PasswordModel.New)" />
|
||||
|
||||
<div class="actions">
|
||||
<button type="submit">Passwort ändern</button>
|
||||
</div>
|
||||
</EditForm>
|
||||
}
|
||||
</section>
|
||||
|
||||
@code {
|
||||
private readonly Dictionary<string, string> _errors = [];
|
||||
|
||||
[SupplyParameterFromForm(FormName = "password")] private PasswordModel? Model { get; set; }
|
||||
|
||||
[SupplyParameterFromQuery(Name = "password")] private string? Changed { get; set; }
|
||||
|
||||
protected override void OnInitialized() => Model ??= new PasswordModel();
|
||||
|
||||
private async Task ChangeAsync()
|
||||
{
|
||||
if (AdminAuthenticator.ValidateNewPassword(Model!.New, Model.Confirmation) is { } error)
|
||||
{
|
||||
_errors[nameof(PasswordModel.New)] = error;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!await Admin.TryChangePasswordAsync(Model.Current ?? "", Model.New!))
|
||||
{
|
||||
_errors[nameof(PasswordModel.Current)] = "Aktuelles Passwort falsch.";
|
||||
return;
|
||||
}
|
||||
|
||||
Navigation.NavigateTo("/settings?password=changed");
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@
|
||||
@inject IConfiguration Configuration
|
||||
@inject RuntimeSettingsStore Store
|
||||
@inject AdminAuthenticator Admin
|
||||
@inject IOptions<PortOptions> Ports
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
<PageTitle>Flypaper · Einstellungen</PageTitle>
|
||||
@@ -42,7 +43,7 @@ else if (Saved == "reset")
|
||||
<InputTextArea id="trap-paths" @bind-Value="Model!.TrapPaths" rows="10" class="mono" />
|
||||
<FieldError Errors="_errors" Field="@nameof(SettingsModel.TrapPaths)" />
|
||||
|
||||
<label for="hosts">Zusätzliche bekannte Hosts <span class="muted">(einer pro Zeile, z. B. beispiel.de oder *.beispiel.de)</span></label>
|
||||
<label for="hosts">Bekannte Hosts <span class="muted">(einer pro Zeile, z. B. beispiel.de oder *.beispiel.de; werden auf dem Fallen-Port nur bei Fallenpfaden gefangen, sonst 404)</span></label>
|
||||
<InputTextArea id="hosts" @bind-Value="Model!.ExtraKnownHosts" rows="4" class="mono" />
|
||||
<FieldError Errors="_errors" Field="@nameof(SettingsModel.ExtraKnownHosts)" />
|
||||
|
||||
@@ -89,6 +90,8 @@ else if (Saved == "reset")
|
||||
|
||||
<TrapDataSection />
|
||||
|
||||
<PasswordSection />
|
||||
|
||||
<section class="card">
|
||||
<h2>Nur per Umgebungsvariable</h2>
|
||||
<p class="muted">Gelten ab Containerstart und lassen sich hier nicht ändern.</p>
|
||||
@@ -97,7 +100,8 @@ else if (Saved == "reset")
|
||||
<tr><th>Datenbank</th><td class="mono">@DatabasePath</td></tr>
|
||||
<tr><th>Bekannte Hosts</th><td class="mono">@Format(Configuration.GetSection("Flypaper:Http:KnownHosts").Get<string[]>())</td></tr>
|
||||
<tr><th>Vertrauenswürdige Proxies</th><td class="mono">@Format(Configuration.GetSection("Flypaper:Http:TrustedProxies").Get<string[]>())</td></tr>
|
||||
<tr><th>Admin-Passwort</th><td>@(Admin.IsConfigured ? "gesetzt" : "nicht gesetzt")</td></tr>
|
||||
<tr><th>Admin-Passwort</th><td>@(Admin.UsesEnvironmentPassword ? "per Umgebungsvariable" : "im Dashboard festgelegt")</td></tr>
|
||||
<tr><th>Ports</th><td class="mono">Falle @Ports.Value.Trap, Dashboard @Ports.Value.Dashboard</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
@page "/setup"
|
||||
@layout EmptyLayout
|
||||
@attribute [AllowAnonymous]
|
||||
@using Flypaper.Web.Auth
|
||||
@inject AdminAuthenticator Admin
|
||||
@inject NavigationManager Navigation
|
||||
|
||||
<PageTitle>Flypaper · Einrichten</PageTitle>
|
||||
|
||||
<h1 class="login-title">Flypaper einrichten</h1>
|
||||
|
||||
<form method="post" action="/auth/setup" class="card form">
|
||||
<AntiforgeryToken />
|
||||
<p class="muted">Lege das Admin-Passwort für das Dashboard fest. Diese Seite ist nur erreichbar, solange noch kein Passwort existiert.</p>
|
||||
<label for="password">Passwort <span class="muted">(mindestens @AdminAuthenticator.MinimumPasswordLength Zeichen)</span></label>
|
||||
<input id="password" name="password" type="password" autocomplete="new-password" minlength="@AdminAuthenticator.MinimumPasswordLength" autofocus required />
|
||||
<label for="confirmation">Passwort wiederholen</label>
|
||||
<input id="confirmation" name="confirmation" type="password" autocomplete="new-password" required />
|
||||
@if (Error is not null)
|
||||
{
|
||||
<p class="error">@Error</p>
|
||||
}
|
||||
<button type="submit">Passwort festlegen</button>
|
||||
</form>
|
||||
|
||||
@code {
|
||||
[SupplyParameterFromQuery(Name = "error")] private string? Error { get; set; }
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (await Admin.IsConfiguredAsync())
|
||||
{
|
||||
Navigation.NavigateTo("/login");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,13 @@ using Microsoft.AspNetCore.DataProtection;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.WebHost.ConfigureKestrel(options => options.AddServerHeader = false);
|
||||
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();
|
||||
|
||||
@@ -6,13 +6,12 @@
|
||||
}
|
||||
},
|
||||
"Flypaper": {
|
||||
"Http": {
|
||||
"KnownHosts": [
|
||||
"localhost"
|
||||
]
|
||||
},
|
||||
"Admin": {
|
||||
"Password": "dev"
|
||||
},
|
||||
"Ports": {
|
||||
"Trap": 5247,
|
||||
"Dashboard": 5248
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user