Skip to content

Commit b83bd55

Browse files
authored
Merge branch 'master' into master
2 parents 1b4e2d9 + 943f4c2 commit b83bd55

35 files changed

Lines changed: 324 additions & 94 deletions

File tree

‎apps/dav/lib/Connector/PublicAuth.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
*/
3030
namespace OCA\DAV\Connector;
3131

32-
use OC\Security\Bruteforce\Throttler;
3332
use OCP\IRequest;
3433
use OCP\ISession;
34+
use OCP\Security\Bruteforce\IThrottler;
3535
use OCP\Share\Exceptions\ShareNotFound;
3636
use OCP\Share\IManager;
3737
use OCP\Share\IShare;
@@ -48,12 +48,12 @@ class PublicAuth extends AbstractBasic {
4848
private IManager $shareManager;
4949
private ISession $session;
5050
private IRequest $request;
51-
private Throttler $throttler;
51+
private IThrottler $throttler;
5252

5353
public function __construct(IRequest $request,
5454
IManager $shareManager,
5555
ISession $session,
56-
Throttler $throttler) {
56+
IThrottler $throttler) {
5757
$this->request = $request;
5858
$this->shareManager = $shareManager;
5959
$this->session = $session;

‎apps/dav/lib/Connector/Sabre/Auth.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636
use Exception;
3737
use OC\Authentication\Exceptions\PasswordLoginForbiddenException;
3838
use OC\Authentication\TwoFactorAuth\Manager;
39-
use OC\Security\Bruteforce\Throttler;
4039
use OC\User\Session;
4140
use OCA\DAV\Connector\Sabre\Exception\PasswordLoginForbidden;
4241
use OCA\DAV\Connector\Sabre\Exception\TooManyRequests;
4342
use OCP\IRequest;
4443
use OCP\ISession;
44+
use OCP\Security\Bruteforce\IThrottler;
4545
use OCP\Security\Bruteforce\MaxDelayReached;
4646
use Psr\Log\LoggerInterface;
4747
use Sabre\DAV\Auth\Backend\AbstractBasic;
@@ -58,13 +58,13 @@ class Auth extends AbstractBasic {
5858
private IRequest $request;
5959
private ?string $currentUser = null;
6060
private Manager $twoFactorManager;
61-
private Throttler $throttler;
61+
private IThrottler $throttler;
6262

6363
public function __construct(ISession $session,
6464
Session $userSession,
6565
IRequest $request,
6666
Manager $twoFactorManager,
67-
Throttler $throttler,
67+
IThrottler $throttler,
6868
string $principalPrefix = 'principals/users/') {
6969
$this->session = $session;
7070
$this->userSession = $userSession;

‎apps/dav/lib/Direct/DirectHome.php‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
*/
2727
namespace OCA\DAV\Direct;
2828

29-
use OC\Security\Bruteforce\Throttler;
3029
use OCA\DAV\Db\DirectMapper;
3130
use OCP\AppFramework\Db\DoesNotExistException;
3231
use OCP\AppFramework\Utility\ITimeFactory;
3332
use OCP\EventDispatcher\IEventDispatcher;
3433
use OCP\Files\IRootFolder;
3534
use OCP\IRequest;
35+
use OCP\Security\Bruteforce\IThrottler;
3636
use Sabre\DAV\Exception\Forbidden;
3737
use Sabre\DAV\Exception\MethodNotAllowed;
3838
use Sabre\DAV\Exception\NotFound;
@@ -49,18 +49,20 @@ class DirectHome implements ICollection {
4949
/** @var ITimeFactory */
5050
private $timeFactory;
5151

52-
/** @var Throttler */
52+
/** @var IThrottler */
5353
private $throttler;
5454

5555
/** @var IRequest */
5656
private $request;
57+
58+
/** @var IEventDispatcher */
5759
private $eventDispatcher;
5860

5961
public function __construct(
6062
IRootFolder $rootFolder,
6163
DirectMapper $mapper,
6264
ITimeFactory $timeFactory,
63-
Throttler $throttler,
65+
IThrottler $throttler,
6466
IRequest $request,
6567
IEventDispatcher $eventDispatcher
6668
) {

‎apps/dav/lib/Direct/ServerFactory.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
*/
2828
namespace OCA\DAV\Direct;
2929

30-
use OC\Security\Bruteforce\Throttler;
3130
use OCA\DAV\Connector\Sabre\MaintenancePlugin;
3231
use OCA\DAV\Db\DirectMapper;
3332
use OCP\AppFramework\Utility\ITimeFactory;
@@ -37,12 +36,14 @@
3736
use OCP\IL10N;
3837
use OCP\IRequest;
3938
use OCP\L10N\IFactory;
39+
use OCP\Security\Bruteforce\IThrottler;
4040

4141
class ServerFactory {
4242
/** @var IConfig */
4343
private $config;
4444
/** @var IL10N */
4545
private $l10n;
46+
/** @var IEventDispatcher */
4647
private $eventDispatcher;
4748

4849
public function __construct(IConfig $config, IFactory $l10nFactory, IEventDispatcher $eventDispatcher) {
@@ -56,7 +57,7 @@ public function createServer(string $baseURI,
5657
IRootFolder $rootFolder,
5758
DirectMapper $mapper,
5859
ITimeFactory $timeFactory,
59-
Throttler $throttler,
60+
IThrottler $throttler,
6061
IRequest $request): Server {
6162
$home = new DirectHome($rootFolder, $mapper, $timeFactory, $throttler, $request, $this->eventDispatcher);
6263
$server = new Server($home);

‎apps/dav/tests/unit/Connector/PublicAuthTest.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
*/
2727
namespace OCA\DAV\Tests\unit\Connector;
2828

29-
use OC\Security\Bruteforce\Throttler;
3029
use OCP\IRequest;
3130
use OCP\ISession;
31+
use OCP\Security\Bruteforce\IThrottler;
3232
use OCP\Share\Exceptions\ShareNotFound;
3333
use OCP\Share\IManager;
3434
use OCP\Share\IShare;
@@ -50,7 +50,7 @@ class PublicAuthTest extends \Test\TestCase {
5050
private $shareManager;
5151
/** @var \OCA\DAV\Connector\PublicAuth */
5252
private $auth;
53-
/** @var Throttler|\PHPUnit\Framework\MockObject\MockObject */
53+
/** @var IThrottler|\PHPUnit\Framework\MockObject\MockObject */
5454
private $throttler;
5555

5656
/** @var string */
@@ -68,7 +68,7 @@ protected function setUp(): void {
6868
$this->shareManager = $this->getMockBuilder(IManager::class)
6969
->disableOriginalConstructor()
7070
->getMock();
71-
$this->throttler = $this->getMockBuilder(Throttler::class)
71+
$this->throttler = $this->getMockBuilder(IThrottler::class)
7272
->disableOriginalConstructor()
7373
->getMock();
7474

‎apps/dav/tests/unit/Connector/Sabre/AuthTest.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@
3030
namespace OCA\DAV\Tests\unit\Connector\Sabre;
3131

3232
use OC\Authentication\TwoFactorAuth\Manager;
33-
use OC\Security\Bruteforce\Throttler;
3433
use OC\User\Session;
3534
use OCP\IRequest;
3635
use OCP\ISession;
3736
use OCP\IUser;
37+
use OCP\Security\Bruteforce\IThrottler;
3838
use Sabre\DAV\Server;
3939
use Sabre\HTTP\RequestInterface;
4040
use Sabre\HTTP\ResponseInterface;
@@ -57,7 +57,7 @@ class AuthTest extends TestCase {
5757
private $request;
5858
/** @var Manager */
5959
private $twoFactorManager;
60-
/** @var Throttler */
60+
/** @var IThrottler */
6161
private $throttler;
6262

6363
protected function setUp(): void {
@@ -71,7 +71,7 @@ protected function setUp(): void {
7171
$this->twoFactorManager = $this->getMockBuilder(Manager::class)
7272
->disableOriginalConstructor()
7373
->getMock();
74-
$this->throttler = $this->getMockBuilder(Throttler::class)
74+
$this->throttler = $this->getMockBuilder(IThrottler::class)
7575
->disableOriginalConstructor()
7676
->getMock();
7777
$this->auth = new \OCA\DAV\Connector\Sabre\Auth(

‎apps/dav/tests/unit/Direct/DirectHomeTest.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
*/
2828
namespace OCA\DAV\Tests\Unit\Direct;
2929

30-
use OC\Security\Bruteforce\Throttler;
3130
use OCA\DAV\Db\Direct;
3231
use OCA\DAV\Db\DirectMapper;
3332
use OCA\DAV\Direct\DirectFile;
@@ -37,6 +36,7 @@
3736
use OCP\EventDispatcher\IEventDispatcher;
3837
use OCP\Files\IRootFolder;
3938
use OCP\IRequest;
39+
use OCP\Security\Bruteforce\IThrottler;
4040
use Sabre\DAV\Exception\Forbidden;
4141
use Sabre\DAV\Exception\MethodNotAllowed;
4242
use Sabre\DAV\Exception\NotFound;
@@ -53,7 +53,7 @@ class DirectHomeTest extends TestCase {
5353
/** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
5454
private $timeFactory;
5555

56-
/** @var Throttler|\PHPUnit\Framework\MockObject\MockObject */
56+
/** @var IThrottler|\PHPUnit\Framework\MockObject\MockObject */
5757
private $throttler;
5858

5959
/** @var IRequest */
@@ -71,7 +71,7 @@ protected function setUp(): void {
7171
$this->directMapper = $this->createMock(DirectMapper::class);
7272
$this->rootFolder = $this->createMock(IRootFolder::class);
7373
$this->timeFactory = $this->createMock(ITimeFactory::class);
74-
$this->throttler = $this->createMock(Throttler::class);
74+
$this->throttler = $this->createMock(IThrottler::class);
7575
$this->request = $this->createMock(IRequest::class);
7676
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
7777

‎apps/files_sharing/lib/AppInfo/Application.php‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,14 @@
6565
use OCP\Files\Events\BeforeZipCreatedEvent;
6666
use OCP\Files\IRootFolder;
6767
use OCP\Group\Events\GroupChangedEvent;
68+
use OCP\Group\Events\GroupDeletedEvent;
6869
use OCP\Group\Events\UserAddedEvent;
6970
use OCP\IDBConnection;
7071
use OCP\IGroup;
7172
use OCP\IUserSession;
7273
use OCP\Share\Events\ShareCreatedEvent;
7374
use OCP\User\Events\UserChangedEvent;
75+
use OCP\User\Events\UserDeletedEvent;
7476
use OCP\Util;
7577
use Psr\Container\ContainerInterface;
7678
use Symfony\Component\EventDispatcher\GenericEvent as OldGenericEvent;
@@ -104,7 +106,9 @@ function () use ($c) {
104106

105107
$context->registerNotifierService(Notifier::class);
106108
$context->registerEventListener(UserChangedEvent::class, DisplayNameCache::class);
109+
$context->registerEventListener(UserDeletedEvent::class, DisplayNameCache::class);
107110
$context->registerEventListener(GroupChangedEvent::class, GroupDisplayNameCache::class);
111+
$context->registerEventListener(GroupDeletedEvent::class, GroupDisplayNameCache::class);
108112
}
109113

110114
public function boot(IBootContext $context): void {

‎apps/files_sharing/lib/Cache.php‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
use OCP\Files\StorageNotAvailableException;
4242
use OCP\ICacheFactory;
4343
use OCP\IUserManager;
44+
use OCP\Share\IShare;
4445

4546
/**
4647
* Metadata cache for shared files
@@ -55,15 +56,22 @@ class Cache extends CacheJail {
5556
private ?string $ownerDisplayName = null;
5657
private $numericId;
5758
private DisplayNameCache $displayNameCache;
59+
private IShare $share;
5860

5961
/**
6062
* @param SharedStorage $storage
6163
*/
62-
public function __construct($storage, ICacheEntry $sourceRootInfo, DisplayNameCache $displayNameCache) {
64+
public function __construct(
65+
$storage,
66+
ICacheEntry $sourceRootInfo,
67+
DisplayNameCache $displayNameCache,
68+
IShare $share
69+
) {
6370
$this->storage = $storage;
6471
$this->sourceRootInfo = $sourceRootInfo;
6572
$this->numericId = $sourceRootInfo->getStorageId();
6673
$this->displayNameCache = $displayNameCache;
74+
$this->share = $share;
6775

6876
parent::__construct(
6977
null,
@@ -150,7 +158,7 @@ protected function formatCacheEntry($entry, $path = null) {
150158

151159
try {
152160
if (isset($entry['permissions'])) {
153-
$entry['permissions'] &= $this->storage->getShare()->getPermissions();
161+
$entry['permissions'] &= $this->share->getPermissions();
154162
} else {
155163
$entry['permissions'] = $this->storage->getPermissions($entry['path']);
156164
}
@@ -159,7 +167,7 @@ protected function formatCacheEntry($entry, $path = null) {
159167
// (IDE may say the exception is never thrown – false negative)
160168
$sharePermissions = 0;
161169
}
162-
$entry['uid_owner'] = $this->storage->getOwner('');
170+
$entry['uid_owner'] = $this->share->getShareOwner();
163171
$entry['displayname_owner'] = $this->getOwnerDisplayName();
164172
if ($path === '') {
165173
$entry['is_share_mount_point'] = true;
@@ -169,7 +177,7 @@ protected function formatCacheEntry($entry, $path = null) {
169177

170178
private function getOwnerDisplayName() {
171179
if (!$this->ownerDisplayName) {
172-
$uid = $this->storage->getOwner('');
180+
$uid = $this->share->getShareOwner();
173181
$this->ownerDisplayName = $this->displayNameCache->getDisplayName($uid) ?? $uid;
174182
}
175183
return $this->ownerDisplayName;

‎apps/files_sharing/lib/SharedStorage.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,8 @@ public function getCache($path = '', $storage = null) {
413413
$this->cache = new \OCA\Files_Sharing\Cache(
414414
$storage,
415415
$sourceRoot,
416-
\OC::$server->get(DisplayNameCache::class)
416+
\OC::$server->get(DisplayNameCache::class),
417+
$this->getShare()
417418
);
418419
return $this->cache;
419420
}

0 commit comments

Comments
 (0)