summaryrefslogtreecommitdiffstats
path: root/lib/private/Server.php
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2023-08-14 18:46:59 +0200
committerJoas Schilling <coding@schilljs.com>2023-08-23 06:44:05 +0200
commitbefa2f6d51231c9f79f4c66457424870c120517a (patch)
tree921e9a5aff1fbc492bb85d770ce19a2b16841bbb /lib/private/Server.php
parent7d795d020397947745940be89a3e0719a6c3177a (diff)
downloadnextcloud-server-befa2f6d51231c9f79f4c66457424870c120517a.tar.gz
nextcloud-server-befa2f6d51231c9f79f4c66457424870c120517a.zip
feat(security): Add a bruteforce protection backend base on memcache
Similar to the ratelimit backend Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/Server.php')
-rw-r--r--lib/private/Server.php12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 516dc0b6e8b..bb073891d03 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -1011,6 +1011,18 @@ class Server extends ServerContainer implements IServerContainer {
/** @deprecated 19.0.0 */
$this->registerDeprecatedAlias('Throttler', Throttler::class);
$this->registerAlias(IThrottler::class, Throttler::class);
+
+ $this->registerService(\OC\Security\Bruteforce\Backend\IBackend::class, function ($c) {
+ $config = $c->get(\OCP\IConfig::class);
+ if (ltrim($config->getSystemValueString('memcache.distributed', ''), '\\') === \OC\Memcache\Redis::class) {
+ $backend = $c->get(\OC\Security\Bruteforce\Backend\MemoryCacheBackend::class);
+ } else {
+ $backend = $c->get(\OC\Security\Bruteforce\Backend\DatabaseBackend::class);
+ }
+
+ return $backend;
+ });
+
$this->registerService('IntegrityCodeChecker', function (ContainerInterface $c) {
// IConfig and IAppManager requires a working database. This code
// might however be called when ownCloud is not yet setup.