Skip to content

Commit 24be03e

Browse files
authored
Merge pull request #52205 from nextcloud/backport/50905/stable30
2 parents 37da5ff + 2fdb509 commit 24be03e

5 files changed

Lines changed: 45 additions & 1 deletion

File tree

apps/files_sharing/lib/Controller/ShareAPIController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ public function deleteShare(string $id): DataResponse {
554554
* 200: Share created
555555
*/
556556
#[NoAdminRequired]
557+
#[UserRateLimit(limit: 20, period: 600)]
557558
public function createShare(
558559
?string $path = null,
559560
?int $permissions = null,
@@ -2115,7 +2116,7 @@ private function checkInheritedAttributes(IShare $share): void {
21152116
* 200: The email notification was sent successfully
21162117
*/
21172118
#[NoAdminRequired]
2118-
#[UserRateLimit(limit: 5, period: 120)]
2119+
#[UserRateLimit(limit: 10, period: 600)]
21192120
public function sendShareEmail(string $id, $password = ''): DataResponse {
21202121
try {
21212122
$share = $this->getShareById($id);

build/integration/config/behat.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,13 @@ default:
233233
regular_user_password: 123456
234234
- RemoteContext:
235235
remote: http://localhost:8080
236+
ratelimiting:
237+
paths:
238+
- "%paths.base%/../ratelimiting_features"
239+
contexts:
240+
- RateLimitingContext:
241+
baseUrl: http://localhost:8080
242+
admin:
243+
- admin
244+
- admin
245+
regular_user_password: 123456
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
/**
3+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
4+
* SPDX-License-Identifier: AGPL-3.0-or-later
5+
*/
6+
use Behat\Behat\Context\Context;
7+
8+
class RateLimitingContext implements Context {
9+
use BasicStructure;
10+
use CommandLine;
11+
use Provisioning;
12+
13+
/**
14+
* @BeforeScenario @RateLimiting
15+
*/
16+
public function enableRateLimiting() {
17+
// Enable rate limiting for the tests.
18+
// Ratelimiting is disabled by default, so we need to enable it
19+
$this->runOcc(['config:system:set', 'ratelimit.protection.enabled', '--value', 'true', '--type', 'bool']);
20+
}
21+
22+
/**
23+
* @AfterScenario @RateLimiting
24+
*/
25+
public function disableRateLimiting() {
26+
// Restore the default rate limiting configuration.
27+
// Ratelimiting is disabled by default, so we need to disable it
28+
$this->runOcc(['config:system:set', 'ratelimit.protection.enabled', '--value', 'false', '--type', 'bool']);
29+
}
30+
}

build/integration/features/ratelimiting.feature renamed to build/integration/ratelimiting_features/ratelimiting.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
22
# SPDX-License-Identifier: AGPL-3.0-or-later
3+
@RateLimiting
34
Feature: ratelimiting
45

56
Background:

build/integration/run.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ INSTALLED=$($OCC status | grep installed: | cut -d " " -f 5)
2020
if [ "$INSTALLED" == "true" ]; then
2121
# Disable bruteforce protection because the integration tests do trigger them
2222
$OCC config:system:set auth.bruteforce.protection.enabled --value false --type bool
23+
# Disable rate limit protection because the integration tests do trigger them
24+
$OCC config:system:set ratelimit.protection.enabled --value false --type bool
2325
# Allow local remote urls otherwise we can not share
2426
$OCC config:system:set allow_local_remote_servers --value true --type bool
2527
else

0 commit comments

Comments
 (0)