1
0

RateLimitTestController.php 904 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCA\Testing\Controller;
  7. use OCP\AppFramework\Controller;
  8. use OCP\AppFramework\Http\Attribute\AnonRateLimit;
  9. use OCP\AppFramework\Http\Attribute\NoCSRFRequired;
  10. use OCP\AppFramework\Http\Attribute\PublicPage;
  11. use OCP\AppFramework\Http\Attribute\UserRateLimit;
  12. use OCP\AppFramework\Http\JSONResponse;
  13. class RateLimitTestController extends Controller {
  14. /**
  15. * @return JSONResponse
  16. */
  17. #[PublicPage]
  18. #[NoCSRFRequired]
  19. #[UserRateLimit(limit: 5, period: 100)]
  20. #[AnonRateLimit(limit: 1, period: 100)]
  21. public function userAndAnonProtected() {
  22. return new JSONResponse();
  23. }
  24. /**
  25. * @return JSONResponse
  26. */
  27. #[PublicPage]
  28. #[NoCSRFRequired]
  29. #[AnonRateLimit(limit: 1, period: 10)]
  30. public function onlyAnonProtected() {
  31. return new JSONResponse();
  32. }
  33. }