Skip to content

Commit 2757d86

Browse files
authored
Merge pull request #8 from codebar-ag/main
main/production
2 parents 6aee4bb + 86b5fa7 commit 2757d86

File tree

21 files changed

+268
-598
lines changed

21 files changed

+268
-598
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace App\Http\Middleware;
4+
5+
use Closure;
6+
use Illuminate\Support\Facades\Vite;
7+
8+
class AddContentSecurityPolicyHeaders
9+
{
10+
public function handle($request, Closure $next): string
11+
{
12+
return $next($request)->withHeaders([
13+
'Content-Security-Policy' => "script-src 'nonce-".Vite::cspNonce()."'",
14+
]);
15+
}
16+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace App\Security\Generator;
4+
5+
use Illuminate\Support\Facades\Vite;
6+
use Spatie\Csp\Nonce\NonceGenerator;
7+
8+
class LaravelViteNonceGenerator implements NonceGenerator
9+
{
10+
public function generate(): string
11+
{
12+
return Vite::cspNonce();
13+
}
14+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace App\Security\Presets;
4+
5+
use Spatie\Csp\Directive;
6+
use Spatie\Csp\Keyword;
7+
use Spatie\Csp\Policy;
8+
use Spatie\Csp\Preset;
9+
10+
class MyCspPreset implements Preset
11+
{
12+
public function configure(Policy $policy): void
13+
{
14+
$policy->add(Directive::BASE, Keyword::SELF);
15+
16+
$policy->add(Directive::CONNECT, Keyword::SELF);
17+
$policy->add(Directive::DEFAULT, Keyword::SELF);
18+
$policy->add(Directive::FONT, Keyword::SELF);
19+
$policy->add(Directive::FORM_ACTION, Keyword::SELF);
20+
$policy->add(Directive::IMG, [
21+
Keyword::SELF,
22+
'data:',
23+
]);
24+
$policy->add(Directive::MEDIA, Keyword::SELF);
25+
$policy->add(Directive::OBJECT, Keyword::NONE);
26+
27+
$policy->add(Directive::SCRIPT, Keyword::SELF);
28+
29+
$policy->add(Directive::STYLE, [
30+
Keyword::SELF,
31+
Keyword::UNSAFE_INLINE,
32+
]);
33+
34+
// Fathom Analytics
35+
$policy->add(Directive::SCRIPT, 'cdn.usefathom.com');
36+
$policy->add(Directive::CONNECT, 'cdn.usefathom.com');
37+
$policy->add(Directive::SCRIPT, 'cdn-eu.usefathom.com');
38+
$policy->add(Directive::CONNECT, 'cdn-eu.usefathom.com');
39+
}
40+
}

app/Security/SecurityPolicyBasic.php

Lines changed: 0 additions & 27 deletions
This file was deleted.

bootstrap/app.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22

3+
use App\Http\Middleware\AddContentSecurityPolicyHeaders;
34
use App\Http\Middleware\SetLanguage;
45
use App\Providers\AppServiceProvider;
56
use App\Providers\EventServiceProvider;
@@ -24,6 +25,7 @@
2425
->withMiddleware(function (Middleware $middleware) {
2526
$middleware->web(append: [
2627
AddCspHeaders::class,
28+
// AddContentSecurityPolicyHeaders::class,
2729
AddFeaturePolicyHeaders::class,
2830
SetLanguage::class,
2931
CacheResponse::class,

composer.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,15 @@
99
"license": "MIT",
1010
"require": {
1111
"php": "^8.4",
12-
"blade-ui-kit/blade-heroicons": "^2.3",
13-
"blade-ui-kit/blade-icons": "^1.6",
1412
"codebar-ag/laravel-flysystem-cloudinary": "^v12.0.1",
1513
"filament/filament": "^3.3",
1614
"laravel/framework": "^v12.1.1",
1715
"laravel/tinker": "^2.10.1",
1816
"league/flysystem-aws-s3-v3": "^3.28",
1917
"livewire/livewire": "^3.5",
2018
"mazedlx/laravel-feature-policy": "^2.2",
21-
"owenvoke/blade-fontawesome": "^2.6",
2219
"sammyjo20/lasso": "3.4.0",
23-
"spatie/laravel-csp": "^2.9",
20+
"spatie/laravel-csp": "^3.8",
2421
"spatie/laravel-flash": "^1.10",
2522
"spatie/laravel-health": "^1.27",
2623
"spatie/laravel-honeypot": "^4.5",

composer.lock

Lines changed: 19 additions & 76 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)