Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ public function deleteShare(string $id): DataResponse {
* 200: Share created
*/
#[NoAdminRequired]
#[UserRateLimit(limit: 20, period: 600)]
public function createShare(
?string $path = null,
?int $permissions = null,
Expand Down Expand Up @@ -2150,7 +2151,7 @@ private function checkInheritedAttributes(IShare $share): void {
* 200: The email notification was sent successfully
*/
#[NoAdminRequired]
#[UserRateLimit(limit: 5, period: 120)]
#[UserRateLimit(limit: 10, period: 600)]
public function sendShareEmail(string $id, $password = ''): DataResponse {
try {
$share = $this->getShareById($id);
Expand Down
11 changes: 11 additions & 0 deletions build/integration/config/behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,14 @@ default:
regular_user_password: 123456
- RemoteContext:
remote: http://localhost:8080

ratelimiting:
paths:
- "%paths.base%/../ratelimiting_features"
contexts:
- RateLimitingContext:
baseUrl: http://localhost:8080
admin:
- admin
- admin
regular_user_password: 123456
30 changes: 30 additions & 0 deletions build/integration/features/bootstrap/RateLimitingContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
use Behat\Behat\Context\Context;

class RateLimitingContext implements Context {
use BasicStructure;
use CommandLine;
use Provisioning;

/**
* @BeforeScenario @RateLimiting
*/
public function enableRateLimiting() {
// Enable rate limiting for the tests.
// Ratelimiting is disabled by default, so we need to enable it
$this->runOcc(['config:system:set', 'ratelimit.protection.enabled', '--value', 'true', '--type', 'bool']);
}

/**
* @AfterScenario @RateLimiting
*/
public function disableRateLimiting() {
// Restore the default rate limiting configuration.
// Ratelimiting is disabled by default, so we need to disable it
$this->runOcc(['config:system:set', 'ratelimit.protection.enabled', '--value', 'false', '--type', 'bool']);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
@RateLimiting
Feature: ratelimiting

Background:
Expand Down
2 changes: 2 additions & 0 deletions build/integration/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ INSTALLED=$($OCC status | grep installed: | cut -d " " -f 5)
if [ "$INSTALLED" == "true" ]; then
# Disable bruteforce protection because the integration tests do trigger them
$OCC config:system:set auth.bruteforce.protection.enabled --value false --type bool
# Disable rate limit protection because the integration tests do trigger them
$OCC config:system:set ratelimit.protection.enabled --value false --type bool
# Allow local remote urls otherwise we can not share
$OCC config:system:set allow_local_remote_servers --value true --type bool
# Allow self signed certificates
Expand Down
Loading