Add persisted runtime settings page with cookie login

This commit is contained in:
Tom committed 2026-11-14 13:54:02 +01:00
1 parent b561924efa
commit 37987a394a
43 files changed
+1346 -61

No files matched your search

@@ -0,0 +1,22 @@
using System.Security.Cryptography;
using System.Text;
using Microsoft.Extensions.Options;
namespace Flypaper.Web.Auth;
public sealed class AdminAuthenticator(IOptions<AdminOptions> options)
{
public bool IsConfigured => !string.IsNullOrEmpty(options.Value.Password);
public bool Verify(string? candidate)
{
if (!IsConfigured || string.IsNullOrEmpty(candidate))
{
return false;
}
return CryptographicOperations.FixedTimeEquals(Hash(candidate), Hash(options.Value.Password!));
}
private static byte[] Hash(string value) => SHA256.HashData(Encoding.UTF8.GetBytes(value));
}