浏览代码

Send Clear-Site-Data expect for Chrome

Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
tags/v18.0.0beta3
Daniel Kesselberg 4 年前
父节点
当前提交
9378a6b411
没有帐户链接到提交者的电子邮件
共有 2 个文件被更改,包括 34 次插入2 次删除
  1. 6
    2
      core/Controller/LoginController.php
  2. 28
    0
      tests/Core/Controller/LoginControllerTest.php

+ 6
- 2
core/Controller/LoginController.php 查看文件

@@ -33,9 +33,9 @@

namespace OC\Core\Controller;

use OC\AppFramework\Http\Request;
use OC\Authentication\Login\Chain;
use OC\Authentication\Login\LoginData;
use OC\Authentication\TwoFactorAuth\Manager;
use OC\Security\Bruteforce\Throttler;
use OC\User\Session;
use OC_App;
@@ -128,7 +128,11 @@ class LoginController extends Controller {

$this->session->set('clearingExecutionContexts', '1');
$this->session->close();
$response->addHeader('Clear-Site-Data', '"cache", "storage"');

if (!$this->request->isUserAgent([Request::USER_AGENT_CHROME, Request::USER_AGENT_ANDROID_MOBILE_CHROME])) {
$response->addHeader('Clear-Site-Data', '"cache", "storage"');
}

return $response;
}


+ 28
- 0
tests/Core/Controller/LoginControllerTest.php 查看文件

@@ -128,6 +128,10 @@ class LoginControllerTest extends TestCase {
->method('getCookie')
->with('nc_token')
->willReturn(null);
$this->request
->expects($this->once())
->method('isUserAgent')
->willReturn(false);
$this->config
->expects($this->never())
->method('deleteUserValue');
@@ -142,12 +146,36 @@ 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())
->method('getCookie')
->with('nc_token')
->willReturn('MyLoginToken');
$this->request
->expects($this->once())
->method('isUserAgent')
->willReturn(false);
$user = $this->createMock(IUser::class);
$user
->expects($this->once())

正在加载...
取消
保存