public function testPublicFolder() { $p = new Path('/admin/public/path/to/Folder/'); $this->assertEquals('admin', $p->getUserId()); $this->assertTrue($p->getIsPublic()); $this->assertTrue($p->getIsFolder()); $this->assertFalse($p->getIsDocument()); $this->assertEquals('path', $p->getModuleName()); }
public function getObject(Request $request, $tokenInfo) { $path = new Path($request->getUrl()->getPathInfo()); // allow requests to public files (GET|HEAD) without authentication if ($path->getIsPublic() && $path->getIsDocument()) { return $this->getDocument($path, $request, $tokenInfo); } // past this point we MUST be authenticated if (null === $tokenInfo) { $e = new UnauthorizedException('unauthorized', 'must authenticate to view folder listing'); $e->addScheme('Bearer', array('realm' => 'remoteStorage API')); throw $e; } if ($path->getIsFolder()) { return $this->getFolder($path, $request, $tokenInfo); } return $this->getDocument($path, $request, $tokenInfo); }