Browse Source
Merge pull request #42544 from HLFH/fix-chrome-logout
Fix Slow logout on Chrome-like browsers
pull/42633/head
Louis
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
30 additions and
6 deletions
-
core/Controller/LoginController.php
-
tests/Core/Controller/LoginControllerTest.php
|
|
|
@ -35,6 +35,7 @@ declare(strict_types=1); |
|
|
|
*/ |
|
|
|
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; |
|
|
|
@ -105,8 +106,10 @@ class LoginController extends Controller { |
|
|
|
$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"'); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -143,8 +143,9 @@ class LoginControllerTest extends TestCase { |
|
|
|
->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'); |
|
|
|
@ -159,6 +160,26 @@ class LoginControllerTest extends TestCase { |
|
|
|
$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()) |
|
|
|
@ -167,8 +188,8 @@ class LoginControllerTest extends TestCase { |
|
|
|
->willReturn('MyLoginToken'); |
|
|
|
$this->request |
|
|
|
->expects($this->once()) |
|
|
|
->method('getServerProtocol') |
|
|
|
->willReturn('https'); |
|
|
|
->method('isUserAgent') |
|
|
|
->willReturn(false); |
|
|
|
$user = $this->createMock(IUser::class); |
|
|
|
$user |
|
|
|
->expects($this->once()) |
|
|
|
|