Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable3.2] fix(setup): Rate limit auto config attempts #8711

Merged
merged 1 commit into from
Aug 21, 2023
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
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\Service\AutoConfig\MxRecord;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\Attribute\UserRateLimit;
use OCP\IRequest;
use OCP\Security\IRemoteHostValidator;
use function in_array;
Expand All @@ -60,10 +61,12 @@ public function __construct(IRequest $request,
* @param string $email
*
* @NoAdminRequired
* @UserRateThrottle(limit: 5, period: 60)
*
* @return JsonResponse
*/
#[TrapError]
#[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,10 +81,12 @@ public function queryIspdb(string $email): JsonResponse {
* @param string $email
*
* @NoAdminRequired
* @UserRateThrottle(limit: 5, period: 60)
*
* @return JsonResponse
*/
#[TrapError]
#[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,10 +103,12 @@ public function queryMx(string $email): JsonResponse {
* @param int $port
*
* @NoAdminRequired
* @UserRateThrottle(limit: 10, period: 60)
*
* @return JsonResponse
*/
#[TrapError]
#[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 @@ -638,6 +638,8 @@ export default {
this.feedback = t('mail', 'SMTP connection failed')
} else if (error.message === CONSENT_ABORTED) {
this.feedback = t('mail', 'Authorization pop-up 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
Loading