Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1e37164
Add support for public shares to file rooms
danxuliu Jul 18, 2018
37f2f71
Add integration tests for files shared by link
danxuliu Aug 14, 2019
d1a3e69
Add integration tests for self-joined users in files shared by link
danxuliu Aug 14, 2019
f2e7806
Add self-joined users and guests to the candidate mentions in file rooms
danxuliu Aug 14, 2019
fc6d2a4
Add integration tests for mentions in a file shared by link
danxuliu Aug 14, 2019
6b04fb7
Fix avatar container height during calls
danxuliu Sep 16, 2019
094b9b3
Add support for Talk sidebar in public share pages
danxuliu Aug 15, 2019
18a1037
Add basic acceptance tests for the Talk sidebar in the public share page
danxuliu Aug 16, 2019
465059d
Add acceptance tests for Talk sidebar in public share page to Drone
danxuliu Aug 16, 2019
1521c5f
Add acceptance tests for registered users in the public share page
danxuliu Aug 16, 2019
f6ac589
Add acceptance tests for mentioning users in the Files app
danxuliu Aug 16, 2019
b8be6a7
Add acceptance tests for mentions in the public share page
danxuliu Aug 16, 2019
3361774
Add acceptance tests for chats in a file shared by link
danxuliu Aug 16, 2019
bab3557
Add acceptance tests for chats in a file shared by link with a password
danxuliu Aug 16, 2019
744de08
Correctly check if the share has a password and if it was entered cor…
nickvergessen Aug 16, 2019
2f58186
Add integration tests for getting the room for link share with password
danxuliu Aug 17, 2019
6b0a0dc
Do not add system message for self joined users to file rooms
danxuliu Aug 19, 2019
ad37a86
Add integration tests for the "user_added" system message
danxuliu Aug 19, 2019
2f12dc9
Add wrapper around "OC.getCurrentUser()" to be able to override the user
danxuliu Sep 25, 2019
4b9a47a
Override the current user when getting the room for a public share page
danxuliu Sep 25, 2019
68797f3
Fix guest avatars in public share page
danxuliu Sep 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Correctly check if the share has a password and if it was entered cor…
…rectly.

This prevents joining the room for a file shared by link and protected
by password if the password has not been entered yet.

Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen authored and danxuliu committed Sep 27, 2019
commit 744de08ddb8de182c1076f3d78e2250ab861b2f6
11 changes: 11 additions & 0 deletions lib/Controller/PublicShareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
use OCP\Files\FileInfo;
use OCP\Files\NotFoundException;
use OCP\IRequest;
use OCP\ISession;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager as ShareManager;
use OCP\Share\IShare;
Expand All @@ -41,6 +42,8 @@ class PublicShareController extends OCSController {

/** @var ShareManager */
private $shareManager;
/** @var ISession */
private $session;
/** @var TalkSession */
private $talkSession;
/** @var Manager */
Expand All @@ -50,11 +53,13 @@ public function __construct(
$appName,
IRequest $request,
ShareManager $shareManager,
ISession $session,
TalkSession $talkSession,
Manager $manager
) {
parent::__construct($appName, $request);
$this->shareManager = $shareManager;
$this->session = $session;
$this->talkSession = $talkSession;
$this->manager = $manager;
}
Expand Down Expand Up @@ -89,6 +94,12 @@ public function __construct(
public function getRoom(string $shareToken) {
try {
$share = $this->shareManager->getShareByToken($shareToken);
if ($share->getPassword() !== null) {
$shareId = $this->session->get('public_link_authenticated');
if ($share->getId() !== $shareId) {
throw new ShareNotFound();
}
}
} catch (ShareNotFound $e) {
return new DataResponse([], Http::STATUS_NOT_FOUND);
}
Expand Down
13 changes: 12 additions & 1 deletion lib/Files/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
use OCP\ISession;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager as IShareManager;
use OCP\Share\IShare;
Expand All @@ -36,14 +37,18 @@ class Util {

/** @var IRootFolder */
private $rootFolder;
/** @var ISession */
private $session;
/** @var IShareManager */
private $shareManager;
/** @var array[] */
private $accessLists = [];

public function __construct(IRootFolder $rootFolder,
ISession $session,
IShareManager $shareManager) {
$this->rootFolder = $rootFolder;
$this->session = $session;
$this->shareManager = $shareManager;
}

Expand All @@ -70,7 +75,13 @@ public function canUserAccessFile(string $fileId, string $userId): bool {

public function canGuestAccessFile(string $shareToken): bool {
try {
$this->shareManager->getShareByToken($shareToken);
$share = $this->shareManager->getShareByToken($shareToken);
if ($share->getPassword() !== null) {
$shareId = $this->session->get('public_link_authenticated');
if ($share->getId() !== $shareId) {
throw new ShareNotFound();
}
}
return true;
} catch (ShareNotFound $e) {
return false;
Expand Down
5 changes: 5 additions & 0 deletions tests/php/Files/UtilTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use OCP\Files\Node;
use OCP\Files\IRootFolder;
use OCP\Files\Storage\IStorage;
use OCP\ISession;
use OCP\Share\IManager;
use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
Expand Down Expand Up @@ -94,11 +95,15 @@ public function testGetGroupFolderNode(string $fileId, string $userId, array $no
->with($userId)
->willReturn($userFolder);

/** @var ISession|MockObject $session */
$session = $this->createMock(ISession::class);

/** @var IManager|MockObject $shareManager */
$shareManager = $this->createMock(IManager::class);

$util = new Util(
$rootFolder,
$session,
$shareManager
);
$result = $util->getGroupFolderNode($fileId, $userId);
Expand Down