2017-04-12 18:32:48 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2024-06-02 13:26:54 +00:00
|
|
|
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2017-04-12 18:32:48 +00:00
|
|
|
*/
|
|
|
|
namespace OCA\Testing\Controller;
|
|
|
|
|
|
|
|
use OCP\AppFramework\Controller;
|
2024-07-25 11:14:50 +00:00
|
|
|
use OCP\AppFramework\Http\Attribute\AnonRateLimit;
|
|
|
|
use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
|
|
|
|
use OCP\AppFramework\Http\Attribute\PublicPage;
|
|
|
|
use OCP\AppFramework\Http\Attribute\UserRateLimit;
|
2017-04-12 18:32:48 +00:00
|
|
|
use OCP\AppFramework\Http\JSONResponse;
|
|
|
|
|
|
|
|
class RateLimitTestController extends Controller {
|
|
|
|
/**
|
|
|
|
* @return JSONResponse
|
|
|
|
*/
|
2024-07-25 11:14:50 +00:00
|
|
|
#[PublicPage]
|
|
|
|
#[NoCSRFRequired]
|
|
|
|
#[UserRateLimit(limit: 5, period: 100)]
|
|
|
|
#[AnonRateLimit(limit: 1, period: 100)]
|
2017-04-12 18:32:48 +00:00
|
|
|
public function userAndAnonProtected() {
|
|
|
|
return new JSONResponse();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return JSONResponse
|
|
|
|
*/
|
2024-07-25 11:14:50 +00:00
|
|
|
#[PublicPage]
|
|
|
|
#[NoCSRFRequired]
|
|
|
|
#[AnonRateLimit(limit: 1, period: 10)]
|
2017-04-12 18:32:48 +00:00
|
|
|
public function onlyAnonProtected() {
|
|
|
|
return new JSONResponse();
|
|
|
|
}
|
|
|
|
}
|