-
Notifications
You must be signed in to change notification settings - Fork 2
Implement security hardening with CSP and localized assets #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -56,6 +56,23 @@ | |||||
| app.UseAuthentication(); | ||||||
| app.UseAuthorization(); | ||||||
|
|
||||||
| app.Use((context, next) => | ||||||
| { | ||||||
| context.Request.Scheme = "https"; | ||||||
| return next(); | ||||||
| }); | ||||||
|
Comment on lines
+59
to
+63
|
||||||
|
|
||||||
| app.Use(async (context, next) => | ||||||
| { | ||||||
| if(context.Response.Headers.IsReadOnly == false) | ||||||
| { | ||||||
| string csp = app.Configuration["Content-Security-Policy"] | ||||||
| ?? "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; object-src 'self' data:; frame-src 'self' data:;"; | ||||||
|
||||||
| ?? "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; object-src 'self' data:; frame-src 'self' data:;"; | |
| ?? "default-src 'self'; script-src 'self'; style-src 'self'; img-src 'self' data:; font-src 'self'; object-src 'self' data:; frame-src 'self' data:;"; |
Copilot
AI
Mar 11, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Response.Headers.Append("Content-Security-Policy", ...) can result in multiple CSP headers if something upstream/downstream also sets CSP, and browsers will apply the intersection which can be confusing to debug. Prefer setting the header value (e.g., Headers["Content-Security-Policy"] = ...) or only add it when it's not already present.
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This script is now served from a local static file but doesn't use cache-busting (asp-append-version) like the other local assets in this project. Consider adding asp-append-version="true" to avoid clients being stuck with an old vis-network.min.js after deployments.