ErrorView und ErrorViewModel hinzugefügt; ContactLink als Singleton konfiguriert, serialisiert aus appSettings

This commit is contained in:
Developer 02
2024-04-25 16:17:10 +02:00
parent 8efe321cc7
commit 966b7de3c4
15 changed files with 695 additions and 59 deletions

View File

@@ -14,6 +14,7 @@ using DigitalData.Core.API;
using Microsoft.AspNetCore.Authentication.Cookies;
using DigitalData.Core.Application;
using DigitalData.UserManager.Application.MappingProfiles;
using EnvelopeGenerator.Web.Models;
var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
logger.Info("Logging initialized!");
@@ -105,10 +106,10 @@ try
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options =>
{
options.Cookie.HttpOnly = true; // Makes the cookie inaccessible to client-side scripts for security
options.Cookie.HttpOnly = true; // Makes the cookie inaccessible to client-side scripts for security
options.Cookie.SecurePolicy = CookieSecurePolicy.SameAsRequest; // Ensures cookies are sent over HTTPS only
options.Cookie.SameSite = SameSiteMode.Strict; // Protects against CSRF attacks by restricting how cookies are sent with requests from external sites
// Set up event handlers for dynamic login and logout paths
options.Events = new CookieAuthenticationEvents
{
OnRedirectToLogin = context =>
@@ -132,6 +133,8 @@ try
};
});
builder.Services.AddSingleton(_ => builder.Configuration.GetSection("ContactLink").Get<ContactLink>() ?? new ContactLink());
builder.Services.AddCookieConsentSettings();
var app = builder.Build();