Skip to content

Commit

Permalink
Merge pull request #48884 from nextcloud/bugfix/noid/allow-to-force-d…
Browse files Browse the repository at this point in the history
…b-throttler

feat(bruteforce): Allow forcing the database throttler
  • Loading branch information
nickvergessen authored Oct 25, 2024
2 parents 92179c8 + 6854af0 commit 631f6d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion config/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@

/**
* The timeout in seconds for synchronizing address books, e.g. federated system address books (as run by `occ federation:sync-addressbooks`).
*
*
* Defaults to ``30`` seconds
*/
'carddav_sync_request_timeout' => 30,
Expand Down Expand Up @@ -405,6 +405,17 @@
*/
'auth.bruteforce.protection.enabled' => true,

/**
* Whether the brute force protection should write into the database even when a memory cache is available
*
* Using the database is most likely worse for performance, but makes investigating
* issues a lot easier as it's possible to look directly at the table to see all
* logged remote addresses and actions.
*
* Defaults to ``false``
*/
'auth.bruteforce.protection.force.database' => false,

/**
* Whether the brute force protection shipped with Nextcloud should be set to testing mode.
*
Expand Down
3 changes: 2 additions & 1 deletion lib/private/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,8 @@ public function __construct($webRoot, \OC\Config $config) {

$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) {
if (!$config->getSystemValueBool('auth.bruteforce.protection.force.database', false)
&& 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);
Expand Down

0 comments on commit 631f6d4

Please sign in to comment.