Skip to content

Commit

Permalink
Update connect-src with all permitted sources.
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahelsaig committed Jan 8, 2024
1 parent 204cc49 commit a26713a
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,32 @@ public class CdnContentSecurityPolicyProvider : IContentSecurityPolicyProvider

public ValueTask UpdateAsync(IDictionary<string, string> securityPolicies, HttpContext context)
{
var any = false;

if (PermittedStyleSources.Any())
{
any = true;
MergeValues(securityPolicies, StyleSrc, PermittedStyleSources);
}

if (PermittedScriptSources.Any())
{
any = true;
MergeValues(securityPolicies, ScriptSrc, PermittedScriptSources);
}

if (PermittedFontSources.Any())
{
any = true;
MergeValues(securityPolicies, FontSrc, PermittedFontSources);
}

if (any)
{
var allPermittedSources = PermittedStyleSources.Concat(PermittedScriptSources).Concat(PermittedFontSources);
MergeValues(securityPolicies, ConnectSrc, allPermittedSources);
}

return ValueTask.CompletedTask;
}

Expand Down

0 comments on commit a26713a

Please sign in to comment.