summaryrefslogtreecommitdiffstats
path: root/lib/private/Server.php
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2021-09-13 13:07:37 +0200
committerGitHub <noreply@github.com>2021-09-13 13:07:37 +0200
commit0dcc5c0e9f346912ed8c263950ad91f35a41bff8 (patch)
treec360c1c57b53a007ffec586428901ad1669b2dad /lib/private/Server.php
parentd31456093d3bb2ff55fe0fde07050f07301459d6 (diff)
parent474a5b55d39e621c12947b50ea6c8febfceed7d7 (diff)
downloadnextcloud-server-0dcc5c0e9f346912ed8c263950ad91f35a41bff8.tar.gz
nextcloud-server-0dcc5c0e9f346912ed8c263950ad91f35a41bff8.zip
Merge pull request #28728 from nextcloud/add-database-backend-limiter
Add database ratelimiting backend
Diffstat (limited to 'lib/private/Server.php')
-rw-r--r--lib/private/Server.php18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 6b6a1402a04..a9ea07c27d3 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -787,10 +787,20 @@ class Server extends ServerContainer implements IServerContainer {
$this->registerDeprecatedAlias('Search', ISearch::class);
$this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
- return new \OC\Security\RateLimiting\Backend\MemoryCache(
- $this->get(ICacheFactory::class),
- new \OC\AppFramework\Utility\TimeFactory()
- );
+ $cacheFactory = $c->get(ICacheFactory::class);
+ if ($cacheFactory->isAvailable()) {
+ $backend = new \OC\Security\RateLimiting\Backend\MemoryCacheBackend(
+ $this->get(ICacheFactory::class),
+ new \OC\AppFramework\Utility\TimeFactory()
+ );
+ } else {
+ $backend = new \OC\Security\RateLimiting\Backend\DatabaseBackend(
+ $c->get(IDBConnection::class),
+ new \OC\AppFramework\Utility\TimeFactory()
+ );
+ }
+
+ return $backend;
});
$this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class);