Skip to content

Commit

Permalink
prevent downgrade from https to http
Browse files Browse the repository at this point in the history
also ensures site is always accessed in https
  • Loading branch information
SethSharp committed Nov 17, 2024
1 parent a487b49 commit 48143a9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Kernel extends HttpKernel
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\StrictTransportSecurity::class
];

/**
Expand Down
24 changes: 24 additions & 0 deletions app/Http/Middleware/StrictTransportSecurity.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace App\Http\Middleware;

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

class StrictTransportSecurity
{
/**
* 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);

$response->headers->set('Strict-Transport-Security', 'max-age=63072000; includeSubDomains; preload');

return $response;
}
}

0 comments on commit 48143a9

Please sign in to comment.