Browse Source

Add Clear-Site-Data header

This adds a Clear-Site-Data header to the logout response which will delete all relevant data in the caches which may contain potentially sensitive content.

See https://w3c.github.io/webappsec-clear-site-data/#header for the definition of the types.

Ref https://twitter.com/mikewest/status/877149667909406723

Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
pull/5490/head
Lukas Reschke 8 years ago
parent
commit
2f87fb6b45
No known key found for this signature in database GPG Key ID: B9F6980CF6E759B1
  1. 4
      core/Controller/LoginController.php
  2. 2
      tests/Core/Controller/LoginControllerTest.php

4
core/Controller/LoginController.php

@ -107,7 +107,9 @@ class LoginController extends Controller {
}
$this->userSession->logout();
return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm'));
$response = new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm'));
$response->addHeader('Clear-Site-Data', '"cache", "cookies", "storage", "executionContexts"');
return $response;
}
/**

2
tests/Core/Controller/LoginControllerTest.php

@ -95,6 +95,7 @@ class LoginControllerTest extends TestCase {
->willReturn('/login');
$expected = new RedirectResponse('/login');
$expected->addHeader('Clear-Site-Data', '"cache", "cookies", "storage", "executionContexts"');
$this->assertEquals($expected, $this->loginController->logout());
}
@ -124,6 +125,7 @@ class LoginControllerTest extends TestCase {
->willReturn('/login');
$expected = new RedirectResponse('/login');
$expected->addHeader('Clear-Site-Data', '"cache", "cookies", "storage", "executionContexts"');
$this->assertEquals($expected, $this->loginController->logout());
}

Loading…
Cancel
Save