承接 virdiggg/header-ci3 相关项目开发

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

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

virdiggg/header-ci3

Composer 安装命令:

composer require virdiggg/header-ci3

包简介

HTTP Header for CodeIgniter 3

README 文档

README

Is helmetjs/helmet for CodeIgniter 3/PHP.

HOW TO USE

  • Install this library with composer
composer require virdiggg/header-ci3
  • Load this library on your application/config/config.php or you can create a controller if you don't want to load this on all of your website. Example is application/controller/App.php
<?php defined('BASEPATH') or exit('No direct script access allowed');

use Virdiggg\HeaderCi3\Headers;

class App extends CI_Controller
{
	private $headers;
	public function __construct()
	{
		parent::__construct();
	}

	public function testing1()
	{
		$this->headers = new Headers();
		$this->headers->setHeaders();
		return;
	}

	public function testing2()
	{
		$this->headers = new Headers();
		$this->headers->setContentSecurityPolicy(["default-src 'self'"]);
		$this->headers->setHeaders();
		echo 1;
		return;
	}

	public function testing3()
	{
		$this->headers = new Headers();
		$this->headers->setXDNSPrefetchControl('on');
		$this->headers->setHeaders();
		echo 1;
		return;
	}

	public function test_header()
	{
		$this->headers = new Headers();
		echo 1;
		return;
	}

	public function test_no_header()
	{
		echo 1;
		return;
	}
}
  • Then CURL your website in cmd
curl -I http://localhost/codeigniter/app/test_header/

HTTP/1.1 200 OK
Date: Fri, 08 Sep 2023 00:00:00 GMT
Server: Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.1.10
Content-Type: text/html; charset=UTF-8
curl -I http://localhost/codeigniter/app/test_no_header/

HTTP/1.1 200 OK
Date: Fri, 08 Sep 2023 00:00:00 GMT
Server: Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.1.10
X-Powered-By: PHP/8.1.10
Content-Type: text/html; charset=UTF-8
curl -I http://localhost/codeigniter/app/testing1/

HTTP/1.1 200 OK
Date: Fri, 08 Sep 2023 00:00:00 GMT
Server: Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.1.10
Content-Security-Policy: default-src 'self' base-uri 'self' font-src 'self' https: data: form-action 'self' frame-ancestors 'self' img-src 'self' data: object-src 'none' script-src 'self' script-src-attr 'none' style-src 'self' https: 'unsafe-inline' upgrade-insecure-requests
'unsafe-inline' *.gstatic.com *.googleapis.com *.jquery.com *.jsdelivr.net
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Resource-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
Origin-Agent-Cluster: ?1
Referrer-Policy: no-referrer
X-Content-Type-Options: nosniff
X-DNS-Prefetch-Control: off
X-Download-Options: noopen
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-XSS-Protection: 0
Permissions-Policy: fullscreen=(self), geolocation=(self), camera=(self)
Strict-Transport-Security: max-age=15552000; includeSubDomains
Content-Type: text/html; charset=UTF-8
curl -I http://localhost/codeigniter/app/testing2/

HTTP/1.1 200 OK
Date: Fri, 08 Sep 2023 00:00:00 GMT
Server: Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.1.10
Content-Security-Policy: default-src 'self'
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Resource-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
Origin-Agent-Cluster: ?1
Referrer-Policy: no-referrer
X-Content-Type-Options: nosniff
X-DNS-Prefetch-Control: off
X-Download-Options: noopen
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-XSS-Protection: 0
Permissions-Policy: fullscreen=(self), geolocation=(self), camera=(self)
Strict-Transport-Security: max-age=15552000; includeSubDomains
Content-Type: text/html; charset=UTF-8
curl -I http://localhost/codeigniter/app/testing3/

HTTP/1.1 200 OK
Date: Fri, 08 Sep 2023 00:00:00 GMT
Server: Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.1.10
Content-Security-Policy: default-src 'self' base-uri 'self' font-src 'self' https: data: form-action 'self' frame-ancestors 'self' img-src 'self' data: object-src 'none' script-src 'self' script-src-attr 'none' style-src 'self' https: 'unsafe-inline' upgrade-insecure-requests
'unsafe-inline' *.gstatic.com *.googleapis.com *.jquery.com *.jsdelivr.net
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Resource-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
Origin-Agent-Cluster: ?1
Referrer-Policy: no-referrer
X-Content-Type-Options: nosniff
X-DNS-Prefetch-Control: on
X-Download-Options: noopen
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-XSS-Protection: 0
Permissions-Policy: fullscreen=(self), geolocation=(self), camera=(self)
Strict-Transport-Security: max-age=15552000; includeSubDomains
Content-Type: text/html; charset=UTF-8

EXPLANATIONS

  • Header X-Powered-By will always be removed once you load this library.
  • This will use all the default HTTP Headers
$this->headers = new Headers();
$this->headers->setHeaders();
  • This will modify Content-Security-Policy header, a powerful allow-list of what can happen on your page which mitigates many attacks. Be careful when using this as this can break your page if you're using 3rd party library such as FontAwesome. Parameter is an array.
$this->headers = new Headers();
$this->headers->setContentSecurityPolicy([array]);
$this->headers->setHeaders();
  • This will modify Cross-Origin-Opener-Policy header, it helps process-isolate your page. Parameter is a string.
$this->headers = new Headers();
$this->headers->setCrossOriginOpenerPolicy('string');
$this->headers->setHeaders();
  • This will modify Cross-Origin-Resource-Policy header, it blocks others from loading your resources cross-origin. Parameter is a string.
$this->headers = new Headers();
$this->headers->setCrossOriginResourcePolicy('string');
$this->headers->setHeaders();
  • This will modify Cross-Origin-Embedder-Policy header, it configures embedding cross-origin resources into the document. Parameter is a string.
$this->headers = new Headers();
$this->headers->setCrossOriginResourcePolicy('string');
$this->headers->setHeaders();
  • This will modify Origin-Agent-Cluster header, it changes process isolation to be origin-based. Parameter is a string.
$this->headers = new Headers();
$this->headers->setOriginAgentCluster('string');
$this->headers->setHeaders();
  • This will modify Referrer-Policy header, it controls the Referer header. Parameter is a string.
$this->headers = new Headers();
$this->headers->setReferrerPolicy('string');
$this->headers->setHeaders();
  • This will modify Strict-Transport-Security header, it tells browsers to prefer HTTPS. Parameter is a string.
  • Make sure whether you have CONST ENVIRONMENT or not, if you are not, this will create it's own ENVIRONMENT.
  • If ENVIRONMENT = 'production' (most likely not localhost), it will add this header. Otherwise, no.
$this->headers = new Headers();
$this->headers->setStrictTransportSecurity('string');
$this->headers->setHeaders();
  • This will modify X-Content-Type-Options header, it help avoids MIME sniffing. Parameter is a string.
$this->headers = new Headers();
$this->headers->setXContentTypeOptions('string');
$this->headers->setHeaders();
  • This will modify X-DNS-Prefetch-Control header, it controls DNS prefetching. Parameter is a string.
$this->headers = new Headers();
$this->headers->setXDNSPrefetchControl('string');
$this->headers->setHeaders();
  • This will modify X-Download-Options header, it forces downloads to be saved (Internet Explorer only). Parameter is a string.
$this->headers = new Headers();
$this->headers->setXDownloadOptions('string');
$this->headers->setHeaders();
  • This will modify X-Frame-Options header, a legacy header that mitigates clickjacking attacks. Parameter is a string.
$this->headers = new Headers();
$this->headers->setXFrameOptions('string');
$this->headers->setHeaders();
  • This will modify X-Permitted-Cross-Domain-Policies header, it controls cross-domain behavior for Adobe products, like Acrobat. Parameter is a string.
$this->headers = new Headers();
$this->headers->setXPermittedCrossDomainPolicies('string');
$this->headers->setHeaders();
  • This will modify X-XSS-Protection header, a legacy header that tries to mitigate XSS attacks, but makes things worse, so we disables it. Parameter is a string.
$this->headers = new Headers();
$this->headers->setXXSSProtection('string');
$this->headers->setHeaders();
  • This will modify Permissions-Policy header, it provides mechanisms for web developers to explicitly declare what functionality can and cannot be used on a website. Parameter is a string.
$this->headers = new Headers();
$this->headers->setPermissionPolicy('string');
$this->headers->setHeaders();

virdiggg/header-ci3 适用场景与选型建议

virdiggg/header-ci3 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 24 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 09 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 virdiggg/header-ci3 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 virdiggg/header-ci3 我们能提供哪些服务?
定制开发 / 二次开发

基于 virdiggg/header-ci3 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-09-08