Merge pull request #21491 from owncloud/webdav_auth_no_basic_auth
Also allow 'only cookie' auth to webdav
This commit is contained in:
commit
1f21f0eb73
|
@ -151,7 +151,10 @@ class Auth extends AbstractBasic {
|
||||||
*/
|
*/
|
||||||
private function auth(RequestInterface $request, ResponseInterface $response) {
|
private function auth(RequestInterface $request, ResponseInterface $response) {
|
||||||
if (\OC_User::handleApacheAuth() ||
|
if (\OC_User::handleApacheAuth() ||
|
||||||
($this->userSession->isLoggedIn() && is_null($this->session->get(self::DAV_AUTHENTICATED)))
|
//Fix for broken webdav clients
|
||||||
|
($this->userSession->isLoggedIn() && is_null($this->session->get(self::DAV_AUTHENTICATED))) ||
|
||||||
|
//Well behaved clients that only send the cookie are allowed
|
||||||
|
($this->userSession->isLoggedIn() && $this->session->get(self::DAV_AUTHENTICATED) === $this->userSession->getUser()->getUID() && $request->getHeader('Authorization') === null)
|
||||||
) {
|
) {
|
||||||
$user = $this->userSession->getUser()->getUID();
|
$user = $this->userSession->getUser()->getUID();
|
||||||
\OC_Util::setupFS($user);
|
\OC_Util::setupFS($user);
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
namespace OCA\DAV\Tests\Unit\Connector\Sabre;
|
namespace OCA\DAV\Tests\Unit\Connector\Sabre;
|
||||||
|
|
||||||
|
use OCP\IUser;
|
||||||
use Test\TestCase;
|
use Test\TestCase;
|
||||||
use OCP\ISession;
|
use OCP\ISession;
|
||||||
use OCP\IUserSession;
|
use OCP\IUserSession;
|
||||||
|
@ -29,6 +30,7 @@ use OCP\IUserSession;
|
||||||
* Class Auth
|
* Class Auth
|
||||||
*
|
*
|
||||||
* @package OCA\DAV\Connector\Sabre
|
* @package OCA\DAV\Connector\Sabre
|
||||||
|
* @group DB
|
||||||
*/
|
*/
|
||||||
class Auth extends TestCase {
|
class Auth extends TestCase {
|
||||||
/** @var ISession */
|
/** @var ISession */
|
||||||
|
@ -330,21 +332,31 @@ class Auth extends TestCase {
|
||||||
$httpResponse = $this->getMockBuilder('\Sabre\HTTP\ResponseInterface')
|
$httpResponse = $this->getMockBuilder('\Sabre\HTTP\ResponseInterface')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
/** @var IUser */
|
||||||
|
$user = $this->getMock('OCP\IUser');
|
||||||
|
$user->method('getUID')->willReturn('MyTestUser');
|
||||||
$this->userSession
|
$this->userSession
|
||||||
->expects($this->any())
|
->expects($this->any())
|
||||||
->method('isLoggedIn')
|
->method('isLoggedIn')
|
||||||
->will($this->returnValue(true));
|
->will($this->returnValue(true));
|
||||||
|
$this->userSession
|
||||||
|
->expects($this->any())
|
||||||
|
->method('getUser')
|
||||||
|
->willReturn($user);
|
||||||
$this->session
|
$this->session
|
||||||
->expects($this->once())
|
->expects($this->atLeastOnce())
|
||||||
->method('get')
|
->method('get')
|
||||||
->with('AUTHENTICATED_TO_DAV_BACKEND')
|
->with('AUTHENTICATED_TO_DAV_BACKEND')
|
||||||
->will($this->returnValue('MyTestUser'));
|
->will($this->returnValue('MyTestUser'));
|
||||||
$httpRequest
|
$httpRequest
|
||||||
->expects($this->once())
|
->expects($this->atLeastOnce())
|
||||||
->method('getHeader')
|
->method('getHeader')
|
||||||
->with('Authorization')
|
->with('Authorization')
|
||||||
->will($this->returnValue(null));
|
->will($this->returnValue(null));
|
||||||
$this->auth->check($httpRequest, $httpResponse);
|
$this->assertEquals(
|
||||||
|
[true, 'principals/users/MyTestUser'],
|
||||||
|
$this->auth->check($httpRequest, $httpResponse)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAuthenticateValidCredentials() {
|
public function testAuthenticateValidCredentials() {
|
||||||
|
|
Loading…
Reference in New Issue