File tree Expand file tree Collapse file tree 3 files changed +25
-5
lines changed
tests/unit/Connector/Sabre
build/integration/features Expand file tree Collapse file tree 3 files changed +25
-5
lines changed Original file line number Diff line number Diff line change 2525use OCP \ISession ;
2626use OCP \IUserSession ;
2727use Sabre \DAV \Auth \Backend \AbstractBearer ;
28+ use Sabre \HTTP \RequestInterface ;
29+ use Sabre \HTTP \ResponseInterface ;
2830
2931class BearerAuth extends AbstractBearer {
3032 /** @var IUserSession */
@@ -77,4 +79,16 @@ public function validateBearerToken($bearerToken) {
7779
7880 return false ;
7981 }
82+
83+ /**
84+ * \Sabre\DAV\Auth\Backend\AbstractBearer::challenge sets an WWW-Authenticate
85+ * header which some DAV clients can't handle. Thus we override this function
86+ * and make it simply return a 401.
87+ *
88+ * @param RequestInterface $request
89+ * @param ResponseInterface $response
90+ */
91+ public function challenge (RequestInterface $ request , ResponseInterface $ response ) {
92+ $ response ->setStatus (401 );
93+ }
8094}
Original file line number Diff line number Diff line change 2121
2222namespace OCA \DAV \Tests \unit \Connector \Sabre ;
2323
24- use OC \Authentication \TwoFactorAuth \Manager ;
25- use OC \Security \Bruteforce \Throttler ;
26- use OC \User \Session ;
2724use OCA \DAV \Connector \Sabre \BearerAuth ;
2825use OCP \IRequest ;
2926use OCP \ISession ;
@@ -85,4 +82,13 @@ public function testValidateBearerToken() {
8582
8683 $ this ->assertSame ('principals/users/admin ' , $ this ->bearerAuth ->validateBearerToken ('Token ' ));
8784 }
85+
86+ public function testChallenge () {
87+ /** @var \PHPUnit_Framework_MockObject_MockObject|RequestInterface $request */
88+ $ request = $ this ->createMock (RequestInterface::class);
89+ /** @var \PHPUnit_Framework_MockObject_MockObject|ResponseInterface $response */
90+ $ response = $ this ->createMock (ResponseInterface::class);
91+ $ result = $ this ->bearerAuth ->challenge ($ request , $ response );
92+ $ this ->assertEmpty ($ result );
93+ }
8894}
Original file line number Diff line number Diff line change @@ -8,15 +8,15 @@ Feature: webdav-related
88 Then the HTTP status code should be "401"
99 And there are no duplicate headers
1010 And The following headers should be set
11- |WWW -Authenticate |Basic realm ="Nextcloud ", Bearer realm =" Nextcloud " |
11+ |WWW -Authenticate |Basic realm ="Nextcloud "|
1212
1313 Scenario : Unauthenticated call new dav path
1414 Given using new dav path
1515 When connecting to dav endpoint
1616 Then the HTTP status code should be "401"
1717 And there are no duplicate headers
1818 And The following headers should be set
19- |WWW -Authenticate |Bearer realm =" Nextcloud ", Basic realm ="Nextcloud "|
19+ |WWW -Authenticate |Basic realm ="Nextcloud "|
2020
2121 Scenario : Moving a file
2222 Given using old dav path
You can’t perform that action at this time.
0 commit comments