Secure Headers

bepsvpt/secure-headers image

Secure Headers stats

Downloads
2.1M
Stars
475
Open Issues
2
Forks
45

View on GitHub →

Add security related headers to HTTP response. The package includes Service Providers for easy Laravel integration.

Secure Headers

Add security related headers to HTTP response. The package includes Service Providers for easy Laravel integration.

Version

7.4.0

Supported Laravel Version

5.1 ~ 10.x

Installation

Non Laravel Project

Install using composer

composer require bepsvpt/secure-headers

Copy config file to your project directory

cp vendor/bepsvpt/secure-headers/config/secure-headers.php path/to/your/project/directory

Set up config file

Done!

Laravel Project

Install using composer

composer require bepsvpt/secure-headers

Add service provider in config/app.php ( laravel version < 5.5 )

Bepsvpt\SecureHeaders\SecureHeadersServiceProvider::class,

Publish config file

php artisan vendor:publish --provider="Bepsvpt\SecureHeaders\SecureHeadersServiceProvider"

Add global middleware in app/Http/Kernel.php

\Bepsvpt\SecureHeaders\SecureHeadersMiddleware::class,

Set up config file config/secure-headers.php

Done!

Lumen Project

Install using composer

composer require bepsvpt/secure-headers

Add service provider in bootstrap/app.php

$app->register(Bepsvpt\SecureHeaders\SecureHeadersServiceProvider::class);

Copy config file to project directory

mkdir config
cp vendor/bepsvpt/secure-headers/config/secure-headers.php config/secure-headers.php

Add global middleware in bootstrap/app.php

$app->middleware([
\Bepsvpt\SecureHeaders\SecureHeadersMiddleware::class,
]);

Set up config file config/secure-headers.php

Done!

Usage(Non Laravel Project)

Do not forget to import namespace.

<?php
 
use \Bepsvpt\SecureHeaders\SecureHeaders;

Instance

<?php
 
// instantiate the class by fromFile static method
$secureHeaders = SecureHeaders::fromFile('/path/to/secure-headers.php');
 
// or instantiate the class directly
$config = require '/path/to/secure-headers.php';
 
$config['key'] = 'value'; // modify config value if needed
 
$secureHeaders = new SecureHeaders($config);

Send

// Get headers
$secureHeaders->headers();
 
// Send headers to HTTP response
$secureHeaders->send();

Document and Notice

Please see DOCS for details.

Changelog

Please see CHANGELOG for details.

Upgrade

Please see UPGRADE for details.

License

Secure Headers is licensed under The MIT License (MIT).

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.


Bepsvpt Secure Headers Related Articles

Laravel Bastion - A Stripe-inspired API authentication package image

Laravel Bastion - A Stripe-inspired API authentication package

Read article
Ensuring Secure URLs in Laravel Applications image

Ensuring Secure URLs in Laravel Applications

Read article
The Laravel Security Checklist (Sponsor) image

The Laravel Security Checklist (Sponsor)

Read article
The Certification of Competence for Laravel logo

The Certification of Competence for Laravel

A community-driven, proctored assessment across 4 levels designed to validate real-world Laravel knowledge, from Junior to mastery-level Artisan. Official Vue.js, Official Nuxt, Angular, React, JS certifications also available.

The Certification of Competence for Laravel
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $9500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises