fix: isolate public cookies from legacy application authentication
This commit is contained in:
parent
f620dc0623
commit
681edbd4c3
@ -4,6 +4,7 @@ using PlotDirector.Website.Data;
|
||||
using PlotDirector.Website.Services;
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.Services.AddControllersWithViews();
|
||||
builder.Services.AddAntiforgery(options => options.Cookie.Name = "PlotDirectorWebsiteAntiforgery");
|
||||
builder.Services.AddMemoryCache();
|
||||
var protection = builder.Services.AddDataProtection().SetApplicationName("PlotDirector.Website");
|
||||
if (builder.Configuration["DataProtection:KeysPath"] is string keysPath) protection.PersistKeysToFileSystem(new DirectoryInfo(keysPath));
|
||||
|
||||
@ -9,7 +9,7 @@ namespace PlotDirector.Website.Services;
|
||||
// is bound to the signed-in subject, and is disposable on restart or graph change.
|
||||
public sealed class WritingSolverResultContext(IMemoryCache cache)
|
||||
{
|
||||
private const string Cookie = "pd-solver-result";
|
||||
private const string Cookie = "PlotDirectorWebsiteSolverResult";
|
||||
private static readonly TimeSpan Lifetime = TimeSpan.FromHours(2);
|
||||
private sealed record Entry(string Version, SolverAnswer[] Answers);
|
||||
private static string? Token(HttpContext context) => context.Request.Cookies[Cookie] is { Length: 64 } token
|
||||
|
||||
@ -1,6 +1,14 @@
|
||||
# Merge with the reviewed live PlotDirector configuration; do not enable two vhosts
|
||||
# for the same host. Preserve existing maintenance, verification and ACME locations.
|
||||
map $http_upgrade $plotdirector_website_upgrade { default upgrade; '' close; }
|
||||
map $cookie_PlotDirectorWebsiteAntiforgery $plotdirector_public_antiforgery {
|
||||
default "PlotDirectorWebsiteAntiforgery=$cookie_PlotDirectorWebsiteAntiforgery;";
|
||||
"" "";
|
||||
}
|
||||
map $cookie_PlotDirectorWebsiteSolverResult $plotdirector_public_solver {
|
||||
default "PlotDirectorWebsiteSolverResult=$cookie_PlotDirectorWebsiteSolverResult;";
|
||||
"" "";
|
||||
}
|
||||
server {
|
||||
listen 80; listen [::]:80;
|
||||
server_name plotdirector.com www.plotdirector.com;
|
||||
@ -43,6 +51,7 @@ server {
|
||||
# contains the former application drawer controller name.
|
||||
location ~* ^/HelpDrawer/(?:Image|Article)$ {
|
||||
proxy_pass http://127.0.0.1:5004;
|
||||
proxy_set_header Cookie "$plotdirector_public_antiforgery$plotdirector_public_solver";
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
@ -67,6 +76,7 @@ server {
|
||||
# Retain original public Help and solver URLs, including legacy help redirects.
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:5004;
|
||||
proxy_set_header Cookie "$plotdirector_public_antiforgery$plotdirector_public_solver";
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user