Skip to content

Commit e425720

Browse files
committed
parameterize DefaultSources on site.config
1 parent f8627a7 commit e425720

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

source/DasBlog.Web.UI/Config/site.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112

113113
<CookieConsentEnabled>false</CookieConsentEnabled>
114114

115+
<DefaultSources>data:;https:</DefaultSources>
115116
<SecurityStyleSources>cloud.tinymce.com;cdn.tiny.cloud;cdn.jsdelivr.net;js.nicedit.com;www.google.com;platform.twitter.com;cdn.syndication.twimg.com;fonts.googleapis.com;maxcdn.bootstrapcdn.com</SecurityStyleSources>
116117
<SecurityScriptSources>cloud.tinymce.com;cdn.tiny.cloud;cdn.jsdelivr.net;js.nicedit.com;www.google.com;cse.google.com;cdn.syndication.twimg.com;platform.twitter.com;apis.google.com;www.google-analytics.com;www.googletagservices.com;adservice.google.com;securepubads.g.doubleclick.net;ajax.aspnetcdn.com;ssl.google-analytics.com</SecurityScriptSources>
117118

source/DasBlog.Web.UI/Startup.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,14 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IDasBlog
386386

387387
var SecurityScriptSources = Configuration.GetSection("SecurityScriptSources")?.Value?.Split(";");
388388
var SecurityStyleSources = Configuration.GetSection("SecurityStyleSources")?.Value?.Split(";");
389+
var DefaultSources = Configuration.GetSection("DefaultSources")?.Value?.Split(";");
389390

390-
if (SecurityStyleSources != null && SecurityScriptSources != null)
391+
if (SecurityStyleSources != null && SecurityScriptSources != null && DefaultSources != null)
391392
{
392393
app.UseCsp(options => options
393394
.DefaultSources(s => s.Self()
394-
.CustomSources("data:")
395-
.CustomSources("https:"))
395+
.CustomSources(DefaultSources)
396+
)
396397
.StyleSources(s => s.Self()
397398
.CustomSources(SecurityStyleSources)
398399
.UnsafeInline()

0 commit comments

Comments
 (0)