Skip to content

Commit

Permalink
adjust PrincipalUri as returned from Sabre to effective username
Browse files Browse the repository at this point in the history
backport of #23404
  • Loading branch information
blizzz committed Mar 22, 2016
1 parent 9b2fdc5 commit 90a2be5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 7 additions & 1 deletion apps/dav/lib/connector/sabre/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ private function auth(RequestInterface $request, ResponseInterface $response) {
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;
}
}
6 changes: 3 additions & 3 deletions apps/dav/tests/unit/connector/sabre/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,15 +407,15 @@ public function testAuthenticateValidCredentials() {
$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() {
Expand Down

0 comments on commit 90a2be5

Please sign in to comment.