diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-22 14:49:54 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2016-03-22 14:49:54 +0100 |
commit | 48ec8ab3d34e3d42977eec9490da4638c911ebd3 (patch) | |
tree | c3d13b0b075dc9b1b188b922a7c8de3e01aa5cce | |
parent | 9fc371e436e8f99c862e587efe1b682cb0923e83 (diff) | |
parent | be572de7f075c8dffee6378bcb3a22eaf3f0c144 (diff) | |
download | nextcloud-server-48ec8ab3d34e3d42977eec9490da4638c911ebd3.tar.gz nextcloud-server-48ec8ab3d34e3d42977eec9490da4638c911ebd3.zip |
Merge pull request #23404 from owncloud/fix-22988
adjust PrincipalUri as returned from Sabre to effective username
-rw-r--r-- | apps/dav/lib/connector/sabre/auth.php | 8 | ||||
-rw-r--r-- | apps/dav/tests/unit/connector/sabre/auth.php | 6 |
2 files changed, 10 insertions, 4 deletions
diff --git a/apps/dav/lib/connector/sabre/auth.php b/apps/dav/lib/connector/sabre/auth.php index 4bb07c5f0ed..8c09c9fdc1c 100644 --- a/apps/dav/lib/connector/sabre/auth.php +++ b/apps/dav/lib/connector/sabre/auth.php @@ -169,6 +169,12 @@ class Auth extends AbstractBasic { throw new \Sabre\DAV\Exception\NotAuthenticated('Cannot authenticate over ajax calls'); } - return parent::check($request, $response); + $data = parent::check($request, $response); + if($data[0] === true) { + $startPos = strrpos($data[1], '/') + 1; + $user = $this->userSession->getUser()->getUID(); + $data[1] = substr_replace($data[1], $user, $startPos); + } + return $data; } } diff --git a/apps/dav/tests/unit/connector/sabre/auth.php b/apps/dav/tests/unit/connector/sabre/auth.php index 57ed44f01c0..edb4073bdcb 100644 --- a/apps/dav/tests/unit/connector/sabre/auth.php +++ b/apps/dav/tests/unit/connector/sabre/auth.php @@ -407,15 +407,15 @@ class Auth extends TestCase { $user = $this->getMockBuilder('\OCP\IUser') ->disableOriginalConstructor() ->getMock(); - $user->expects($this->exactly(2)) + $user->expects($this->exactly(3)) ->method('getUID') ->will($this->returnValue('MyTestUser')); $this->userSession - ->expects($this->exactly(2)) + ->expects($this->exactly(3)) ->method('getUser') ->will($this->returnValue($user)); $response = $this->auth->check($server->httpRequest, $server->httpResponse); - $this->assertEquals([true, 'principals/users/username'], $response); + $this->assertEquals([true, 'principals/users/MyTestUser'], $response); } public function testAuthenticateInvalidCredentials() { |