Skip to content

Commit 311c3dc

Browse files
Merge pull request #133 from TechnologyEnhancedLearning/Develop/Fixes/TD-3733-Information-Disclosures
TD-3733:Information Disclosures
2 parents 2b4eb35 + f898a6f commit 311c3dc

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

Auth/LearningHub.Nhs.Auth/Program.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,6 @@
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-
7359
if (app.Environment.IsDevelopment())
7460
{
7561
app.UseDeveloperExceptionPage();

LearningHub.Nhs.UserApi/Program.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
var logger = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();
1212

13+
var csp = "object-src 'none'; frame-ancestors 'none'; sandbox allow-forms allow-same-origin allow-scripts allow-popups; base-uri 'self';";
1314
try
1415
{
1516
logger.Debug("Log Started");
@@ -36,6 +37,17 @@
3637
c.SwaggerEndpoint($"/swagger/{app.Configuration["Swagger:Title"]}/swagger.json", app.Configuration["Swagger:Version"]);
3738
});
3839

40+
app.Use(async (context, next) =>
41+
{
42+
context.Response.Headers.Add("content-security-policy", csp);
43+
context.Response.Headers.Add("Referrer-Policy", "no-referrer");
44+
context.Response.Headers.Add("Strict-Transport-Security", "max-age=31536000; includeSubDomains");
45+
context.Response.Headers.Add("X-Content-Type-Options", "nosniff");
46+
context.Response.Headers.Add("X-Frame-Options", "SAMEORIGIN");
47+
context.Response.Headers.Add("X-XSS-protection", "0");
48+
await next();
49+
});
50+
3951
app.UseMiddleware<ExceptionMiddleware>();
4052

4153
app.UseEndpoints(endpoints => endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}"));

0 commit comments

Comments
 (0)