Skip to content

About

Episerver addon to help manage the sites content security policy.

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

108 Commits

Folders and files

Repository files navigation

Content Security Policy for Optimizley

This repository contains an Optimizley plugin to manage and deliver the content security policy for your site.

Jhoose Security Jhoose Security Core

Features

  • Interface to manage policies.
  • Global 'report only' mode, or specify for each policy.
  • Ability to specify paths which are excluded from outputting the policy header.

Review the Admin Interface documentation for more detail on how to manage the policies.


Installation

Install the package directly from the Optimizley Nuget repository. This will install the admin interface along with the middleware to add the CSP header to the response.

dotnet add package Jhoose.Security.Admin

Configuration

Startup.cs

services.AddJhooseSecurity(IConfiguration configuration, Action<SecurityOptions> options = null);

The Action<SecurityOptions> options is optional and if not specified then the default will be used.

  "JhooseSecurity": {
    "ExclusionPaths": [
      "/episerver"
    ]
  },

ExclusionPaths: Any request which starts with a path specified in this property will not include the CSP header.

app.UseJhooseSecurity();

Nonce tag helper

It is possible to get a nonce added to your inline <script> and <style> tags.

_ViewImports.cshtml

@addTagHelper *, Jhoose.Security.Core
<script nonce src="/assets/js/jquery.min.js"></script>

Recommended Security Headers

The following recommended security headers are now automatically output

Strict-Transport-Security: max-age=31536000;
X-Frame-Options: deny
X-Content-Type-Options: nosniff
X-Permitted-Cross-Domain-Policies: none
Referrer-Policy: strict-origin-when-cross-origin
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Resource-Policy: same-origin

If you need to change the headers, then these are controlled in SecurityOptions class

"JhooseSecurity": {
   "ExclusionPaths":[
      "/episerver"
   ],
   "HttpsRedirection":true,
   "StrictTransportSecurity":{
      "MaxAge":31536000,
      "IncludeSubDomains":true
   },
   "XFrameOptions":{
      "Enabled": true,
      "Mode":0,
      "Domain":""
   },
   "XPermittedCrossDomainPolicies":{
      "Mode":0
   },
   "ReferrerPolicy":{
      "Mode":0
   },
   "CrossOriginEmbedderPolicy":{
      "Mode":1
   },
   "CrossOriginOpenerPolicy":{
      "Mode":2
   },
   "CrossOriginResourcePolicy":{
      "Mode":1
   }
}

Server Header

This isn't removed, the reason being twofold

  1. When hosting within Optimizley DXP, the CDN will obfuscate this value anyway.
  2. The approach is different depending on how you are hosintg your site.

Kestrel

    // program.cs
    .ConfigureWebHostDefaults(webBuilder =>
    {
        webBuilder.ConfigureKestrel(o => o.AddServerHeader = false);
        webBuilder.UseStartup<Startup>();
    });

IIS 10

<!-- web.config -->
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <security>
            <requestFiltering removeServerHeader="true" />
        </security>
    </system.webServer>
</configuration>

About

Episerver addon to help manage the sites content security policy.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages