Skip to content

Commit 50ab026

Browse files
shahabganjilinkdotnet
authored andcommitted
Enhance security header policies with stricter controls
Added Cross-Origin Embedder Policy with UnsafeNone directive to enable embedding YouTube videos, and stricter Permissions Policy for camera, microphone, and geolocation. These updates improve protection against cross-origin attacks and unauthorized access. Updated service configurations in `Program.cs` to apply these enhanced measures. This change bolsters application security and adheres to best practices.
1 parent 48946c4 commit 50ab026

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/LinkDotNet.Blog.Web/Program.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,15 @@ public static async Task Main(string[] args)
2727
private static void RegisterServices(WebApplicationBuilder builder)
2828
{
2929
builder.Services.AddSecurityHeaderPolicies()
30-
.SetDefaultPolicy(p => p.AddDefaultSecurityHeaders())
30+
.SetDefaultPolicy(p =>
31+
p.AddDefaultSecurityHeaders()
32+
.AddCrossOriginEmbedderPolicy(policy => policy.UnsafeNone())
33+
.AddPermissionsPolicy(policy =>
34+
{
35+
policy.AddCamera().None();
36+
policy.AddMicrophone().None();
37+
policy.AddGeolocation().None();
38+
}))
3139
.AddPolicy("API", p => p.AddDefaultApiSecurityHeaders());
3240

3341
builder.Services

0 commit comments

Comments
 (0)