承接 wedevelopnl/silverstripe-csp-custom-scripts 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

wedevelopnl/silverstripe-csp-custom-scripts

最新稳定版本:1.0.0

Composer 安装命令:

composer require wedevelopnl/silverstripe-csp-custom-scripts

包简介

README 文档

README

Description

This Silverstripe module makes sure that any custom scripts added through Requirements are served from a javascript file. The goal of this is to be able to drop script-src: 'unsafe-inline' from your Content-Security-Policy header.

Installation

$ composer require wedevelopnl/silverstripe-csp-custom-scripts

Run a dev/build and you should be all set. If you're using dorsetdigital/silverstripe-enhanced-requirements read "Compatibility" for further instructions

Compatibility

If you're using dorsetdigital/silverstripe-enhanced-requirements you will have to do the override yourself, extend the Enhanced_Requirements class and use the trait to inject the CSP code.

csp.yml

---
Name: csp-enhanced-requirements
After:
  - '#enhanced-requirements'
  - '#csp-requirements'
---
SilverStripe\Core\Injector\Injector:
  SilverStripe\View\Requirements_Backend:
    class: App\View\RequirementsBackend

src/View/RequirementsBackend.php

<?php

declare(strict_types=1);

namespace App\View;

use DorsetDigital\EnhancedRequirements\View\Enhanced_Backend;
use WeDevelop\Csp\View\CspBackendTrait;

final class RequirementsBackend extends Enhanced_Backend
{
    use CspBackendTrait;

    public function includeInHTML($content)
    {
        $this->processCspCustomScripts();

        return parent::includeInHTML($content);
    }
}

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 6
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2024-12-19