Skip to content
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

Alternative syntax #70

Open
gatecrasher63 opened this issue Apr 4, 2023 · 1 comment
Open

Alternative syntax #70

gatecrasher63 opened this issue Apr 4, 2023 · 1 comment

Comments

@gatecrasher63
Copy link

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 ????

@juunas11
Copy link
Owner

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);
    }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants