1
0
mirror of https://github.com/flarum/core.git synced 2025-07-16 14:26:25 +02:00

[huntr] adding cache control headers to the admin area (#3097)

This PR forces the `Cache-Control: no-store, max-age=0` header to the response in the Admin Area. This forces cache to be ignored upon browsing back and forth between pages using the browser controls. Although absolutely no fail safe, it should provide better protection against serving cached pages once an admin has signed out.
This commit is contained in:
Daniël Klabbers
2021-10-08 00:34:22 +02:00
committed by GitHub
parent e48389a86c
commit fe8ca9c0dc
2 changed files with 27 additions and 1 deletions

View File

@@ -61,7 +61,8 @@ class AdminServiceProvider extends AbstractServiceProvider
HttpMiddleware\CheckCsrfToken::class,
Middleware\RequireAdministrateAbility::class,
HttpMiddleware\ReferrerPolicyHeader::class,
HttpMiddleware\ContentTypeOptionsHeader::class
HttpMiddleware\ContentTypeOptionsHeader::class,
Middleware\DisableBrowserCache::class,
];
});

View File

@@ -0,0 +1,25 @@
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Admin\Middleware;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Server\MiddlewareInterface as Middleware;
use Psr\Http\Server\RequestHandlerInterface as Handler;
class DisableBrowserCache implements Middleware
{
public function process(Request $request, Handler $handler): Response
{
$response = $handler->handle($request);
return $response->withHeader('Cache-Control', 'max-age=0, no-store');
}
}