Skip to content

Commit

Permalink
Merge pull request #8835 from nextcloud/fix/setup/rate-limit-auto-con…
Browse files Browse the repository at this point in the history
…fig-attempts-stable2.2

[stable2.2] fix(setup): Rate limit auto config attempts
  • Loading branch information
ChristophWurst authored Sep 13, 2023
2 parents a691ccb + 9e12aae commit ad3df70
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/Controller/AutoConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use OCA\Mail\Validation\RemoteHostValidator;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\UserRateLimit;
use OCP\IRequest;
use function in_array;

Expand All @@ -60,9 +61,11 @@ public function __construct(IRequest $request,
*
* @NoAdminRequired
* @TrapError
* @UserRateThrottle(limit: 5, period: 60)
*
* @return JsonResponse
*/
#[UserRateLimit(limit: 5, period: 60)]
public function queryIspdb(string $email): JsonResponse {
$rfc822Address = new Horde_Mail_Rfc822_Address($email);
if (!$rfc822Address->valid || !$this->hostValidator->isValid($rfc822Address->host)) {
Expand All @@ -78,9 +81,11 @@ public function queryIspdb(string $email): JsonResponse {
*
* @NoAdminRequired
* @TrapError
* @UserRateThrottle(limit: 5, period: 60)
*
* @return JsonResponse
*/
#[UserRateLimit(limit: 5, period: 60)]
public function queryMx(string $email): JsonResponse {
$rfc822Address = new Horde_Mail_Rfc822_Address($email);
if (!$rfc822Address->valid || !$this->hostValidator->isValid($rfc822Address->host)) {
Expand All @@ -98,9 +103,11 @@ public function queryMx(string $email): JsonResponse {
*
* @NoAdminRequired
* @TrapError
* @UserRateThrottle(limit: 10, period: 60)
*
* @return JsonResponse
*/
#[UserRateLimit(limit: 10, period: 60)]
public function testConnectivity(string $host, int $port): JsonResponse {
if (!in_array($port, [143, 993, 465, 587])) {
return JsonResponse::fail('Port not allowed');
Expand Down
2 changes: 2 additions & 0 deletions src/components/AccountForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,8 @@ export default {
this.feedback = t('mail', 'SMTP connection failed')
} else if (error.message === CONSENT_ABORTED) {
this.feedback = t('mail', 'Google authorization popup closed')
} else if (error.response?.status === 429) {
this.feedback = t('mail', 'Configuration discovery temporarily not available. Please try again later.')
} else {
this.feedback = t('mail', 'There was an error while setting up your account')
}
Expand Down

0 comments on commit ad3df70

Please sign in to comment.