cloudgrayau/csp 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cloudgrayau/csp

最新稳定版本:1.3.0

Composer 安装命令:

composer require cloudgrayau/csp

包简介

Content Security Policy manager for Craft CMS

README 文档

README

Content Security Policy manager for Craft CMS.

Screenshot

Requirements

This plugin requires Craft CMS 4.0.0 or later.

Installation

composer require cloudgrayau/csp

CSP Overview

CSP is a Content Security Policy and HTTP Header Response manager for Craft CMS.

SEOmatic Compatibility

This plugin is 100% compatible with any nonces generated by the Automatic Render Enabled setting inside SEOmatic Plugin Settings (General). To ensure compatibility, please set the Nonces for <script> tags to Response Headers inside the SEOmatic Plugin Settings (Tags).

Please note; any script-src CSP tags set within SEOmatic will also be applied. The Content-Security-Policy HTTP Response Header applied by SEOMatic is automatically overridden and/or removed.

Blitz Compatibility

To ensure the Content Security Policy remains compatible with Blitz Caching enabled, please ensure the CSP Mode is set to Meta Tags inside the CSP Settings (Settings).

Setup

The plugin can be configured via the Craft CMS Settings or by using the supplied config/csp.php file. Additional nonces can be configured in your templates as follows:

{# HTML #}
<script src="url/of/script.js" nonce="{{ csp('script-src') }}"></script>
<link href="url/of/style.css" rel="stylesheet" nonce="{{ csp('style-src') }}" />

{# CSS Twig tags #}
{% do view.registerCssFile(url('scss/styles.scss'), { nonce: csp('style-src') }) %}
{% do view.registerCss('<body>background:red;</body>', { nonce: csp('style-src') }) %}

{# JS Twig tags #}
{% do view.registerJsFile(url('js/site.js'), { nonce: csp('script-src') }) %}

Overriding Config

The CSP configuration can be updated in realtime via your templates with twig. This can be useful, for example to disable the CSP on XHR requests.

{% do craft.csp.config({'cspEnabled': false}) %}

Brought to you by Cloud Gray Pty Ltd

统计信息

  • 总下载量: 1.13k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-05-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固