web: založení projektu Helpdesk.Web a layout aplikace
ASP.NET Core MVC (.NET 10) s Bootstrapem 5, layout s menu podle role, chybové stránky, bezpečnostní hlavičky (CSP, Referrer-Policy) a česká kultura. Refs #19, #20
This commit is contained in:
1 parent
b402d9f92c
commit
abd075287c
25 files changed
+523
No files matched your search
@@ -0,0 +1,21 @@
|
||||
namespace Helpdesk.Web.Infrastructure;
|
||||
|
||||
/// <summary>Bezpečnostní hlavičky pro všechny odpovědi webu.</summary>
|
||||
public static class SecurityHeaders
|
||||
{
|
||||
// Všechny skripty a styly jsou ze stejného původu (wwwroot), takže CSP nepotřebuje žádné výjimky.
|
||||
private const string ContentSecurityPolicy =
|
||||
"default-src 'self'; img-src 'self' data: blob:; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'";
|
||||
|
||||
public static IApplicationBuilder UseSecurityHeaders(this IApplicationBuilder app) =>
|
||||
app.Use(async (context, next) =>
|
||||
{
|
||||
var headers = context.Response.Headers;
|
||||
headers.ContentSecurityPolicy = ContentSecurityPolicy;
|
||||
headers.XContentTypeOptions = "nosniff";
|
||||
headers.XFrameOptions = "DENY";
|
||||
// Odkazy z e-mailů nesou token v URL – nesmí uniknout v hlavičce Referer.
|
||||
headers["Referrer-Policy"] = "no-referrer";
|
||||
await next();
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user