aspnetcore-security-headers
aspnetcore-security-headers copied to clipboard
Alternative syntax
This is the normal syntax
app.UseCsp(builder =>
{
builder.ByDefaultAllow
.FromSelf();
});
I need to be more flexible. How would I do this?
var cspBuilder = new Joonasw.AspNetCore.SecurityHeaders.Csp.Builder.CspBuilder();
cspBuilder.ByDefaultAllow.FromSelf();
if (cConfig.HashList != null)
{
foreach (var c in cConfig.HashList)
cspBuilder.AllowStyles.From(c);
}
app.UseCsp( ???? )
what replaces ????
Is there something that prevents you from doing something like this?
app.UseCsp(builder =>
{
builder.ByDefaultAllow
.FromSelf();
if (cConfig.HashList != null)
{
foreach (var c in cConfig.HashList)
builder.AllowStyles.From(c);
}
});