Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions core/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
*/
namespace OC\Core\Controller;

use OC\AppFramework\Http\Request;
use OC\Authentication\Login\Chain;
use OC\Authentication\Login\LoginData;
use OC\Authentication\WebAuthn\Manager as WebAuthnManager;
Expand Down Expand Up @@ -105,8 +106,10 @@ public function logout() {
$this->session->set('clearingExecutionContexts', '1');
$this->session->close();

if ($this->request->getServerProtocol() === 'https') {
// This feature is available only in secure contexts
if (
$this->request->getServerProtocol() === 'https' &&
!$this->request->isUserAgent([Request::USER_AGENT_CHROME, Request::USER_AGENT_ANDROID_MOBILE_CHROME])
) {
$response->addHeader('Clear-Site-Data', '"cache", "storage"');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should have been fixed in the master pr. Instead of excluding Chrome just drop the cache part.

Thats what slows chrome down, because of a 7 years old chrome bug...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

}

Expand Down
29 changes: 25 additions & 4 deletions tests/Core/Controller/LoginControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@ public function testLogoutWithoutToken() {
->with('nc_token')
->willReturn(null);
$this->request
->method('getServerProtocol')
->willReturn('https');
->expects($this->once())
->method('isUserAgent')
->willReturn(false);
$this->config
->expects($this->never())
->method('deleteUserValue');
Expand All @@ -159,6 +160,26 @@ public function testLogoutWithoutToken() {
$this->assertEquals($expected, $this->loginController->logout());
}

public function testLogoutNoClearSiteData() {
$this->request
->expects($this->once())
->method('getCookie')
->with('nc_token')
->willReturn(null);
$this->request
->expects($this->once())
->method('isUserAgent')
->willReturn(true);
$this->urlGenerator
->expects($this->once())
->method('linkToRouteAbsolute')
->with('core.login.showLoginForm')
->willReturn('/login');

$expected = new RedirectResponse('/login');
$this->assertEquals($expected, $this->loginController->logout());
}

public function testLogoutWithToken() {
$this->request
->expects($this->once())
Expand All @@ -167,8 +188,8 @@ public function testLogoutWithToken() {
->willReturn('MyLoginToken');
$this->request
->expects($this->once())
->method('getServerProtocol')
->willReturn('https');
->method('isUserAgent')
->willReturn(false);
$user = $this->createMock(IUser::class);
$user
->expects($this->once())
Expand Down