adjust PrincipalUri as returned from Sabre to effective username
backport of #23404
This commit is contained in:
parent
9b2fdc5358
commit
90a2be58f8
|
@ -169,6 +169,12 @@ class Auth extends AbstractBasic {
|
||||||
throw new \Sabre\DAV\Exception\NotAuthenticated('Cannot authenticate over ajax calls');
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -407,15 +407,15 @@ class Auth extends TestCase {
|
||||||
$user = $this->getMockBuilder('\OCP\IUser')
|
$user = $this->getMockBuilder('\OCP\IUser')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
$user->expects($this->exactly(2))
|
$user->expects($this->exactly(3))
|
||||||
->method('getUID')
|
->method('getUID')
|
||||||
->will($this->returnValue('MyTestUser'));
|
->will($this->returnValue('MyTestUser'));
|
||||||
$this->userSession
|
$this->userSession
|
||||||
->expects($this->exactly(2))
|
->expects($this->exactly(3))
|
||||||
->method('getUser')
|
->method('getUser')
|
||||||
->will($this->returnValue($user));
|
->will($this->returnValue($user));
|
||||||
$response = $this->auth->check($server->httpRequest, $server->httpResponse);
|
$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() {
|
public function testAuthenticateInvalidCredentials() {
|
||||||
|
|
Loading…
Reference in New Issue