mirror of
https://github.com/flarum/framework.git
synced 2025-01-22 12:16:31 +08: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:
parent
2b47e90827
commit
b4772e5399
|
@ -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,
|
||||
];
|
||||
});
|
||||
|
||||
|
|
25
src/Admin/Middleware/DisableBrowserCache.php
Normal file
25
src/Admin/Middleware/DisableBrowserCache.php
Normal 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');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user