-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Attach Security Headers to Laravel Application
- Loading branch information
1 parent
73f9700
commit 58152e6
Showing
70 changed files
with
1,746 additions
and
5,379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,23 @@ | ||
## [Blog Application Installation Guide](https://packagist.org/packages/monish-khatri/blog-application) | ||
## [Laravel Security Headers Installation Guide](https://packagist.org/packages/monish-khatri/security-headers) | ||
<p> | ||
<a href="https://packagist.org/packages/lmonish-khatri/blog-application"> | ||
<img src="https://img.shields.io/packagist/dt/monish-khatri/blog-application" alt="Total Downloads"> | ||
<a href="https://packagist.org/packages/monish-khatri/security-headers"> | ||
<img src="https://img.shields.io/packagist/dt/monish-khatri/security-headers" alt="Total Downloads"> | ||
</a> | ||
<a href="https://packagist.org/packages/monish-khatri/blog-application"> | ||
<img src="https://img.shields.io/packagist/v/monish-khatri/blog-application" alt="Latest Stable Version"> | ||
<a href="https://packagist.org/packages/monish-khatri/security-headers"> | ||
<img src="https://img.shields.io/packagist/v/monish-khatri/security-headers" alt="Latest Stable Version"> | ||
</a> | ||
<a href="https://packagist.org/packages/monish-khatri/blog-application"> | ||
<img src="https://img.shields.io/packagist/l/monish-khatri/blog-application" alt="License"> | ||
<a href="https://packagist.org/packages/monish-khatri/security-headers"> | ||
<img src="https://img.shields.io/packagist/l/monish-khatri/security-headers" alt="License"> | ||
</a> | ||
<a href="https://packagist.org/packages/monish-khatri/blog-application"> | ||
<img src="https://img.shields.io/packagist/stars/monish-khatri/blog-application" alt="License"> | ||
<a href="https://packagist.org/packages/monish-khatri/security-headers"> | ||
<img src="https://img.shields.io/packagist/stars/monish-khatri/security-headers" alt="License"> | ||
</a> | ||
</p> | ||
|
||
### Follow the below steps to install blog application | ||
### Follow the below steps to install security header package | ||
- Install the package using | ||
- `composer require monish-khatri/blog-application` | ||
- `composer require monish-khatri/security-headers` | ||
- Run below command to publish package classes | ||
- `php artisan blog:install` | ||
- Finally, Run the migrations to create package tables | ||
- `php artisan migrate` | ||
- `php artisan security-headers:install` | ||
- You can publish the package config file & change site logo and favicon with email preference | ||
- `php artisan vendor:publish --provider="MonishKhatri\Blog\BlogServiceProvider" --tag="config"` | ||
- `php artisan vendor:publish --provider="MonishKhatri\SecurityHeaders\SecurityHeadersServiceProvider" --tag="config"` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace MonishKhatri\SecurityHeaders\Builders; | ||
|
||
abstract class Builder | ||
{ | ||
/** | ||
* Builder config. | ||
* | ||
* @var array<mixed> | ||
*/ | ||
protected $config = []; | ||
|
||
/** | ||
* Builder constructor. | ||
* | ||
* @param array<mixed> $config | ||
*/ | ||
public function __construct(array $config = []) | ||
{ | ||
$this->config = $config; | ||
} | ||
|
||
/** | ||
* Get result. | ||
* | ||
* @return string | ||
*/ | ||
abstract public function get(): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
namespace MonishKhatri\SecurityHeaders\Builders; | ||
|
||
final class ClearSiteDataBuilder extends Builder | ||
{ | ||
/** | ||
* Clear Site Data whitelist directives. | ||
* | ||
* @var array<string, bool> | ||
*/ | ||
protected $whitelist = [ | ||
'cache' => true, | ||
'cookies' => true, | ||
'storage' => true, | ||
'executionContexts' => true, | ||
]; | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function get(): string | ||
{ | ||
if ($this->config['all'] ?? false) { | ||
return '"*"'; | ||
} | ||
|
||
$targets = array_intersect_key($this->config, $this->whitelist); | ||
|
||
$needs = array_filter($targets); | ||
|
||
$directives = array_map(function (string $directive) { | ||
return sprintf('"%s"', $directive); | ||
}, array_keys($needs)); | ||
|
||
return implode(', ', $directives); | ||
} | ||
} |
Oops, something went wrong.