Optionally enable HSTS using env vars. Useful for testing
This commit is contained in:
1 parent
6dc5a0faf8
commit
779d493513
3 files changed
+22
-1
No files matched your search
@@ -82,6 +82,18 @@ builder.Services.AddScoped<AppState>();
|
||||
|
||||
builder.Services.AddCascadingAuthenticationState();
|
||||
|
||||
// HSTS
|
||||
if (bool.Parse(Environment.GetEnvironmentVariable("ENABLE_HSTS") ?? "false"))
|
||||
{
|
||||
builder.Services.AddHsts(options =>
|
||||
{
|
||||
var hstsSection = builder.Configuration.GetSection("Hsts");
|
||||
options.MaxAge = TimeSpan.FromDays(hstsSection.GetValue<int>("MaxAgeDays", 365));
|
||||
options.IncludeSubDomains = hstsSection.GetValue<bool>("IncludeSubDomains", true);
|
||||
options.Preload = hstsSection.GetValue<bool>("Preload", false);
|
||||
});
|
||||
}
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddRazorComponents()
|
||||
.AddInteractiveServerComponents();
|
||||
|
||||
@@ -16,6 +16,12 @@
|
||||
"Twitter": "",
|
||||
"Mastodon": ""
|
||||
},
|
||||
"Hsts": {
|
||||
"Domain": "nas.oneputleygreen.com",
|
||||
"MaxAgeDays": 365,
|
||||
"IncludeSubDomains": true,
|
||||
"Preload": false
|
||||
},
|
||||
"Authentication": {
|
||||
"Google": {
|
||||
"ClientId": "",
|
||||
|
||||
Reference in new issue
Block a user