Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ APP_KEY=
APP_DEBUG=false
APP_URL=http://localhost

ALLOW_EMBEDS=

FORCE_HTTPS=false

CONTENT_WIDTH=7xl
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,7 @@ class Kernel extends HttpKernel
'signed' => \App\Http\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,

'x-frame-allow' => \App\Http\Middleware\FrameAllowOptions::class,
];
}
26 changes: 26 additions & 0 deletions app/Http/Middleware/FrameAllowOptions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace App\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Symfony\Component\HttpFoundation\Response;

class FrameAllowOptions
{
/**
* Handle an incoming request.
*
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next
*/
public function handle(Request $request, Closure $next): Response
{
$response = $next($request);

if (! blank(config('speedtest.allow_embeds'))) {
$response->header('X-Frame-Options', 'ALLOW FROM '.config('speedtest.allow_embeds'));
}

return $response;
}
}
2 changes: 1 addition & 1 deletion app/Http/Middleware/VerifyCsrfToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ class VerifyCsrfToken extends Middleware
* @var array<int, string>
*/
protected $except = [
//
'/',
];
}
5 changes: 5 additions & 0 deletions config/speedtest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@
'notification_polling' => env('NOTIFICATION_POLLING', '60s'),

'results_polling' => env('RESULTS_POLLING', null),

/**
* Security
*/
'allow_embeds' => env('ALLOW_EMBEDS', null),
];
1 change: 1 addition & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

Route::get('/', HomeController::class)
->middleware('x-frame-allow')
->name('home');

Route::get('/login', function () {
Expand Down