bjorn7495
01/12/2024, 12:00 PMusing System.Linq;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Extensions;
namespace HttpHeaderSecurity.App_Plugins.HttpHeaderSecurity
{
public class HttpHeadersComposer : IComposer
{
public void Compose(IUmbracoBuilder builder)
{
builder.Services.Configure<UmbracoPipelineOptions>(options => options.AddFilter(new UmbracoPipelineFilter("HttpHeaders", postRouting: app => app.Use(async (context, next) =>
{
// Add the security headers
context.Response.Headers["X-Frame-Options"] = "SAMEORIGIN";
// (... more here)
await next();
}))));
}
}
When I add the public class 'HttpHeadersComposer ' to the program.cs directly, the headers are added. So.. how to trigger this code from a package?Jemayn
01/12/2024, 12:47 PMbjorn7495
01/14/2024, 8:29 AM