File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -11,8 +11,28 @@ public static void Main(string[] args)
1111 // Add services to the container.
1212 builder . Services . AddControllersWithViews ( ) ;
1313
14+ // Configure cookie settings
15+ builder . Services . Configure < CookiePolicyOptions > ( options =>
16+ {
17+ options . Secure = CookieSecurePolicy . Always ;
18+ options . HttpOnly = Microsoft . AspNetCore . CookiePolicy . HttpOnlyPolicy . Always ;
19+ } ) ;
20+ builder . Services . AddAntiforgery ( options =>
21+ {
22+ options . Cookie . SecurePolicy = CookieSecurePolicy . Always ;
23+ options . Cookie . HttpOnly = true ;
24+ options . Cookie . SameSite = SameSiteMode . Strict ;
25+ } ) ;
1426 var app = builder . Build ( ) ;
1527
28+ app . Use ( async ( context , next ) =>
29+ {
30+ context . Response . Headers . Add ( "X-Content-Type-Options" , "nosniff" ) ;
31+ context . Response . Headers . Add ( "Content-Security-Policy" , "upgrade-insecure-requests; script-src 'self' 'unsafe-inline' 'unsafe-eval' *.syncfusion.com; style-src 'self' 'unsafe-inline' *.syncfusion.com; frame-src *.syncfusion.com; object-src 'none'; base-uri 'none'; default-src 'self'; font-src 'self' *.syncfusion.com; connect-src 'self' *.syncfusion.com; img-src 'self' *.syncfusion.com; form-action 'self'; frame-ancestors 'self'" ) ;
32+
33+ await next ( ) ;
34+ } ) ;
35+
1636 // Configure the HTTP request pipeline.
1737 if ( ! app . Environment . IsDevelopment ( ) )
1838 {
You can’t perform that action at this time.
0 commit comments