From b4772e53998e56c15eb1af7848161c39d61fb7bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Klabbers?= Date: Fri, 8 Oct 2021 00:34:22 +0200 Subject: [PATCH] [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. --- src/Admin/AdminServiceProvider.php | 3 ++- src/Admin/Middleware/DisableBrowserCache.php | 25 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 src/Admin/Middleware/DisableBrowserCache.php diff --git a/src/Admin/AdminServiceProvider.php b/src/Admin/AdminServiceProvider.php index f07da123b7..c5563aaced 100644 --- a/src/Admin/AdminServiceProvider.php +++ b/src/Admin/AdminServiceProvider.php @@ -61,7 +61,8 @@ public function register() HttpMiddleware\CheckCsrfToken::class, Middleware\RequireAdministrateAbility::class, HttpMiddleware\ReferrerPolicyHeader::class, - HttpMiddleware\ContentTypeOptionsHeader::class + HttpMiddleware\ContentTypeOptionsHeader::class, + Middleware\DisableBrowserCache::class, ]; }); diff --git a/src/Admin/Middleware/DisableBrowserCache.php b/src/Admin/Middleware/DisableBrowserCache.php new file mode 100644 index 0000000000..731ea8157d --- /dev/null +++ b/src/Admin/Middleware/DisableBrowserCache.php @@ -0,0 +1,25 @@ +handle($request); + + return $response->withHeader('Cache-Control', 'max-age=0, no-store'); + } +}