File tree Expand file tree Collapse file tree 2 files changed +12
-14
lines changed
Auth/LearningHub.Nhs.Auth Expand file tree Collapse file tree 2 files changed +12
-14
lines changed Original file line number Diff line number Diff line change 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-
7359if ( app . Environment . IsDevelopment ( ) )
7460{
7561 app . UseDeveloperExceptionPage ( ) ;
Original file line number Diff line number Diff line change 1010
1111var 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';" ;
1314try
1415{
1516 logger . Debug ( "Log Started" ) ;
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?}" ) ) ;
You can’t perform that action at this time.
0 commit comments