Browse Source

We should properly check for 'true' instaed of the bool

tags/v11.0RC2
Roeland Jago Douma 7 years ago
parent
commit
5c718b13b8
No account linked to committer's email address

+ 1
- 1
lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php View File

@@ -153,7 +153,7 @@ class SecurityMiddleware extends Middleware {
*/
if(!$this->request->passesCSRFCheck() && !(
$controller instanceof OCSController &&
$this->request->getHeader('OCS_APIREQUEST') === true)) {
$this->request->getHeader('OCS-APIREQUEST') === 'true')) {
throw new CrossSiteRequestForgeryException();
}
}

+ 2
- 1
tests/lib/AppFramework/Middleware/Security/SecurityMiddlewareTest.php View File

@@ -383,7 +383,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
[$controller, true, true],

[$ocsController, false, true],
[$ocsController, true, true],
[$ocsController, true, false],
];
}

@@ -396,6 +396,7 @@ class SecurityMiddlewareTest extends \Test\TestCase {
public function testCsrfOcsController(Controller $controller, $hasOcsApiHeader, $exception) {
$this->request
->method('getHeader')
->with('OCS-APIREQUEST')
->willReturn($hasOcsApiHeader ? 'true' : null);
$this->request->expects($this->once())
->method('passesStrictCookieCheck')

Loading…
Cancel
Save