Skip to content

Commit

Permalink
Use ConcurrentBag instead of ReadOnlyCollection so these are editable.
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahelsaig committed Jan 8, 2024
1 parent 42ffcb0 commit 204cc49
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Expand All @@ -17,29 +18,29 @@ public class CdnContentSecurityPolicyProvider : IContentSecurityPolicyProvider
/// <summary>
/// Gets the URLs whose <see cref="Uri.Host"/> will be added to the <see cref="StyleSrc"/> directive.
/// </summary>
public static IReadOnlyCollection<Uri> PermittedStyleSources { get; } = new[]
public static ConcurrentBag<Uri> PermittedStyleSources { get; } = new(new[]
{
new Uri("https://fonts.googleapis.com/css"),
new Uri("https://fonts.gstatic.com/"),
new Uri("https://cdn.jsdelivr.net/npm"),
};
});

/// <summary>
/// Gets the URLs whose <see cref="Uri.Host"/> will be added to the <see cref="ScriptSrc"/> directive.
/// </summary>
public static IReadOnlyCollection<Uri> PermittedScriptSources { get; } = new[]
public static ConcurrentBag<Uri> PermittedScriptSources { get; } = new(new[]
{
new Uri("https://cdn.jsdelivr.net/npm"),
};
});

/// <summary>
/// Gets the URLs whose <see cref="Uri.Host"/> will be added to the <see cref="FontSrc"/> directive.
/// </summary>
public static IReadOnlyCollection<Uri> PermittedFontSources { get; } = new[]
public static ConcurrentBag<Uri> PermittedFontSources { get; } = new(new[]
{
new Uri("https://fonts.googleapis.com/"),
new Uri("https://fonts.gstatic.com/"),
};
});

public ValueTask UpdateAsync(IDictionary<string, string> securityPolicies, HttpContext context)
{
Expand Down

0 comments on commit 204cc49

Please sign in to comment.