Skip to content

Commit ccf2104

Browse files
committed
TD-3732: Missing Security Headers
1 parent 0c3fa62 commit ccf2104

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Auth/LearningHub.Nhs.Auth/Program.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,20 @@
5656
await next();
5757
});
5858

59+
app.Use(async (context, next) =>
60+
{
61+
// Add security headers
62+
context.Response.Headers.Add("Strict-Transport-Security", "max-age=31536000; includeSubDomains; preload");
63+
context.Response.Headers.Add("X-Content-Type-Options", "nosniff");
64+
context.Response.Headers.Add("X-XSS-Protection", "1; mode=block");
65+
context.Response.Headers.Add("X-Frame-Options", "DENY");
66+
context.Response.Headers.Add("Content-Security-Policy", "default-src 'self'; script-src 'self'; object-src 'none';");
67+
context.Response.Headers.Add("Referrer-Policy", "no-referrer-when-downgrade");
68+
context.Response.Headers.Add("Feature-Policy", "geolocation 'self'; microphone 'none'; camera 'none'");
69+
70+
await next();
71+
});
72+
5973
if (app.Environment.IsDevelopment())
6074
{
6175
app.UseDeveloperExceptionPage();

0 commit comments

Comments
 (0)