All Projects → bejamas → gatsby-plugin-csp

bejamas / gatsby-plugin-csp

Licence: MIT license
A Gatsby plugin which adds strict Content Security Policy to your project.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to gatsby-plugin-csp

Secure headers
Manages application of security headers with many safe defaults
Stars: ✭ 2,942 (+7255%)
Mutual labels:  csp, content-security-policy
nuxt-security
Module for Nuxt.js to configure security headers and more
Stars: ✭ 46 (+15%)
Mutual labels:  csp, content-security-policy
go-csp-collector
A CSP collector written in Golang
Stars: ✭ 74 (+85%)
Mutual labels:  csp, content-security-policy
gatsby-source-wagtail
Plugin for sourcing Gatsby data from Wagtail CMS
Stars: ✭ 16 (-60%)
Mutual labels:  gatsby-plugin
AspNetCoreMvcAngular
ASP.NET Core MVC with angular in MVC View OpenID Connect Hybrid Flow
Stars: ✭ 54 (+35%)
Mutual labels:  csp
csp
A library for Communicating Sequential Processes in Node.js, built on top of async/await
Stars: ✭ 59 (+47.5%)
Mutual labels:  csp
gatsby-attila-theme-ghost
A Gatsby theme plugin for creating blogs from headless Ghost CMS.
Stars: ✭ 16 (-60%)
Mutual labels:  gatsby-plugin
gatsby-remark-images-anywhere
Handle images with relative, absolute & remote path for gatsby-transformer-remark & gatsby-plugin-mdx
Stars: ✭ 22 (-45%)
Mutual labels:  gatsby-plugin
gatsby-source-behance
Gatsby source plugin for loading information from Behance
Stars: ✭ 17 (-57.5%)
Mutual labels:  gatsby-plugin
gatsby-source-printful
Printful store data for your Gatsby projects
Stars: ✭ 19 (-52.5%)
Mutual labels:  gatsby-plugin
frontreport
Simple frontend logging collector written in Go
Stars: ✭ 23 (-42.5%)
Mutual labels:  csp
gatsby-plugin-asset-path
Move all of your JS and CSS build files, as well as the static folder into a subdirectory of your choice
Stars: ✭ 14 (-65%)
Mutual labels:  gatsby-plugin
pool
A highly flexible process pooling library for Node.js
Stars: ✭ 18 (-55%)
Mutual labels:  csp
gatsby-plugin-intercom-spa
Gatsby plugin to add intercom onto a site
Stars: ✭ 23 (-42.5%)
Mutual labels:  gatsby-plugin
gatsby-source-directus7
Source plugin for pulling data into GatsbyJS from Directus CMS (https://directus.io)
Stars: ✭ 17 (-57.5%)
Mutual labels:  gatsby-plugin
gatsby-graphcms-example
Example of Gatsby source plugin for GraphCMS
Stars: ✭ 32 (-20%)
Mutual labels:  gatsby-plugin
bookmarklets-context-menu
WebExtension allow to execute bookmarklets as privileged scripts
Stars: ✭ 67 (+67.5%)
Mutual labels:  csp
pyGRETA
python Generator of REnewable Time series and mAps
Stars: ✭ 27 (-32.5%)
Mutual labels:  csp
CrySPY
CrySPY is a crystal structure prediction tool written in Python.
Stars: ✭ 58 (+45%)
Mutual labels:  csp
gatsby-source-stripe
Gatsby source plugin for building websites using Stripe as a data source
Stars: ✭ 71 (+77.5%)
Mutual labels:  gatsby-plugin

gatsby-plugin-csp

Content Security Policy (CSP) is an added layer of security that helps to detect and mitigate certain types of attacks, including Cross Site Scripting (XSS) and data injection attacks. These attacks are used for everything from data theft to site defacement to distribution of malware.

gatsby-plugin-csp by default creates strict policy, generates script and style hashes then adds Content-Security-Policy meta tag to the <head> of each page.

Install

npm i gatsby-plugin-csp

or

yarn add gatsby-plugin-csp

How to use

// In your gatsby-config.js
module.exports = {
  plugins: [`gatsby-plugin-csp`]
};

Default Policy:

base-uri 'self';
default-src 'self';
script-src 'self' 'sha256-iF/...GM=' 'sha256-BOv...L4=';
style-src 'self' 'sha256-WCK...jU=';
object-src 'none';
form-action 'self';
font-src 'self' data:;
connect-src 'self';
img-src 'self' data:;

sha256 for every inline script and style is generated automatically during the build process and appended to its directive (script-src or style-src).

Options

Strict CSP can break a lot of things you use on your website, especially 3rd party scripts like Google Analytics. To allow your 3rd party scripts running, you can adjust the policy through the plugin options.

// In your gatsby-config.js
module.exports = {
  plugins: [
    {
      resolve: `gatsby-plugin-csp`,
      options: {
        disableOnDev: true,
        reportOnly: false, // Changes header to Content-Security-Policy-Report-Only for csp testing purposes
        mergeScriptHashes: true, // you can disable scripts sha256 hashes
        mergeStyleHashes: true, // you can disable styles sha256 hashes
        mergeDefaultDirectives: true,
        directives: {
          "script-src": "'self' www.google-analytics.com",
          "style-src": "'self' 'unsafe-inline'",
          "img-src": "'self' data: www.google-analytics.com"
          // you can add your directives or override defaults
        }
      }
    }
  ]
};

Further reading

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].