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
30 changes: 0 additions & 30 deletions docs/modules/ROOT/pages/tmail-backend/configure/rate-limiting.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,3 @@
:navtitle: Rate limiting

See xref:tmail-backend/features/tmailRateLimiting.adoc[this page] for feature explanation.

== Apply rate limiting plans
An administrator needs to rely on the `EnforceRateLimitingPlan` mailet in order to apply rate limiting plans.

Configure mailets to apply rate limiting to senders:

....
<mailet match="All" class="EnforceRateLimitingPlan">
<keyPrefix>some-prefix</keyPrefix>
<operationLimitation>TransitLimitations</operationLimitation>
<exceededProcessor>tooMuchMails</exceededProcessor>
</mailet>
<mailet match="All" class="EnforceRateLimitingPlan">
<keyPrefix>some-prefix</keyPrefix>
<operationLimitation>RelayLimitations</operationLimitation>
<exceededProcessor>tooMuchMails</exceededProcessor>
</mailet>
....

Configure mailet to apply rate limiting to recipients:

....
<mailet match="All" class="EnforceRateLimitingPlan">
<keyPrefix>some-prefix</keyPrefix>
<operationLimitation>DeliveryLimitations</operationLimitation>
<exceededProcessor>tooMuchMails</exceededProcessor>
</mailet>
....

Exceeded emails will be transferred to `tooMuchMails` processor. Please customize this mailet depends on your will.
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@

Manage email rate limiting plans and apply them to your users!

TMail Rate Limiting enable the administrator to manage rate limiting plans and apply those plans to users:
TMail Rate Limiting enable the administrator to manage rate limiting of users:

- Administrator can manage rate limiting plans
- Administrator can manage which rate limiting plans apply to which users
- Administrator can configure mailet configuration, so it can retrieve rate limiting plans and apply to according users
- Administrator can manage rate limiting for each user
- Administrator can configure mailet configuration, so it can retrieve rate limiting and apply to according users

== Manage rate limiting plans via webadmin

The administrator can manage rate limiting plans using xref:tmail-backend/webadmin.adoc#_rate_limiting[Rate Limiting Plan Management Routes]:
The administrator can manage rate limiting using xref:tmail-backend/webadmin.adoc#_rate_limiting[Rate Limiting Plan Management Routes]:

- Creating/updating/getting rate limiting plans
- Attaching/getting/removing plan of a user. Getting list of users belonging to a plan.

The administrator only can apply a plan to a user.

Because of limited number of plans, we do not support removing rate limiting plans.
- Updating/getting rate limiting for users.

273 changes: 0 additions & 273 deletions docs/modules/ROOT/pages/tmail-backend/webadmin.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -191,279 +191,6 @@ Return codes:
- `400` Invalid request
- `404` User does not exist

=== Create a new plan
Allow to create a new rate limiting plan.
....
curl -XPOST http://ip:port/rate-limit-plans/{RateLimitingPlanName}
-H "Content-Type: application/json"
-d '{
"transitLimits": [{
"name": "receivedMailsPerHour",
"periodInSeconds": 3600,
"count": 100,
"size": 2048
},
{
"name": "receivedMailsPerDay",
"periodInSeconds": 86400,
"count": 1000,
"size": 4096
}
],
"relayLimits": [{
"name": "relayMailsPerHour",
"periodInSeconds": 3600,
"count": 100,
"size": 2048
}],
"deliveryLimits": [{
"name": "deliveryMailsPerHour",
"periodInSeconds": 3600,
"count": 100,
"size": 2048
}]
}'
....

Return planId of created plan:
....
{
"planId": "6b427706-11de-4674-a4e7-166983d9119e"
}
....
Return codes:

- `201` The plan created successfully
- `400` Invalid request

=== Edit a plan

....
curl -XPUT http://ip:port/rate-limit-plans/{RateLimitingPlanId}
-H "Content-Type: application/json"
-d '{
"transitLimits": [
{
"name": "receivedMailsPerHour",
"periodInSeconds": 3600,
"count": 100,
"size": 2048
},
{
"name": "receivedMailsPerDay",
"periodInSeconds": 86400
"count": 1000,
"size": 4096
}
],
"relayLimits": [
{
"name": "relayMailsPerHour",
"periodInSeconds": 3600,
"count": 100,
"size": 2048
}
],
"deliveryLimits": [
{
"name": "deliveryMailsPerHour",
"periodInSeconds": 3600,
"count": 100,
"size": 2048
}
]
}'
....

Allow to update an existing plan.

Return codes:

- `204` The plan updated successfully
- `400` Invalid request
- `404` Plan does not exist

=== Get a plan

....
curl -XGET http://ip:port/rate-limit-plans/{RateLimitingPlanId}
....

Return a plan:
....
{
"planId": "65b94d87-b077-4994-bc82-ab87c4e68313",
"planName": "oldPlanName",
"transitLimits": [{
"name": "receivedMailsPerHour",
"periodInSeconds": 3600,
"count": 100,
"size": 2048
},
{
"name": "receivedMailsPerDay",
"periodInSeconds": 86400,
"count": 1000,
"size": 4096
}
],
"relayLimits": [{
"name": "relayMailsPerHour",
"periodInSeconds": 3600,
"count": 100,
"size": 2048
}],
"deliveryLimits": [{
"name": "deliveryMailsPerHour",
"periodInSeconds": 3600,
"count": 100,
"size": 2048
}]
}
....

Return codes:

- `200` Get the plan successfully
- `400` Invalid request
- `404` Plan does not exist

=== Get all plans

....
curl -XGET http://ip:port/rate-limit-plans
....

Return all existing plans:
....
[{
"planId": "524acec6-7910-4137-b862-7ec1ab048404",
"planName": "plan1",
"transitLimits": [{
"name": "receivedMailsPerHour",
"periodInSeconds": 3600,
"count": 100,
"size": 2048
},
{
"name": "receivedMailsPerDay",
"periodInSeconds": 86400,
"count": 1000,
"size": 4096
}
],
"relayLimits": [{
"name": "relayMailsPerHour",
"periodInSeconds": 3600,
"count": 100,
"size": 2048
}],
"deliveryLimits": [{
"name": "deliveryMailsPerHour",
"periodInSeconds": 3600,
"count": 100,
"size": 2048
}]
},
{
"planId": "2fc6b2d7-9b62-42f0-aa8a-5ab62168e0c5",
"planName": "plan2",
"transitLimits": [{
"name": "receivedMailsPerHour",
"periodInSeconds": 3600,
"count": 100,
"size": 2048
},
{
"name": "receivedMailsPerDay",
"periodInSeconds": 86400,
"count": 1000,
"size": 4096
}
],
"relayLimits": [{
"name": "relayMailsPerHour",
"periodInSeconds": 3600,
"count": 100,
"size": 2048
}],
"deliveryLimits": [{
"name": "deliveryMailsPerHour",
"periodInSeconds": 3600,
"count": 100,
"size": 2048
}]
}
]
....

Return codes:

- `200` Get all plans successfully

=== Attach a plan to a user
....
curl -XPUT http://ip:port/users/{username}/rate-limit-plans/{planId}
....

Attach a rate limiting plan to a user. This also can be used to reattach a new plan to that user.

Return codes:

- `204` Attached the plan to the user successfully
- `400` Invalid request
- `404` Either plan or user is not found

=== Get list of users belonging to a plan
....
curl -XGET http://ip:port/rate-limit-plans/{planId}/users
....

Return users belong to a plan:
....
[
"[email protected]",
"[email protected]"
]
....

Return codes:

- `200` Get all users belong to that plan successfully
- `400` Invalid request
- `404` Plan is not found

=== Get plan of a user
....
curl -XGET http://ip:port/users/{username}/rate-limit-plans
....

Return rate limiting planId attached to that user:
....
{
"planId": "02242f08-515c-4170-945e-64afa991f149"
}
....

Return codes:

- `200` Get plan of that user successfully
- `400` Invalid request
- `404` Either user is not found or that user does not have a plan.

=== Revoke plan of a user
....
curl -XDELETE http://ip:port/users/{username}/rate-limit-plans
....

Revoke the plan attached to that user.

Return codes:

- `204` Revoke plan of that user successfully
- `400` Invalid request
- `404` User is not found

== Domain contacts

=== Create a contact
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
import com.linagora.tmail.team.TeamMailboxModule;
import com.linagora.tmail.webadmin.EmailAddressContactRoutesModule;
import com.linagora.tmail.webadmin.OidcBackchannelLogoutRoutesModule;
import com.linagora.tmail.webadmin.RateLimitPlanRoutesModule;
import com.linagora.tmail.webadmin.RateLimitsRoutesModule;
import com.linagora.tmail.webadmin.TeamMailboxRoutesModule;
import com.linagora.tmail.webadmin.archival.InboxArchivalTaskModule;
import com.linagora.tmail.webadmin.cleanup.MailboxesCleanupModule;
Expand Down Expand Up @@ -257,7 +257,7 @@ protected void configure() {
new MailboxRoutesModule(),
new MailQueueRoutesModule(),
new MailRepositoriesRoutesModule(),
new RateLimitPlanRoutesModule(),
new RateLimitsRoutesModule(),
new TeamMailboxModule(),
new TeamMailboxRoutesModule(),
new SieveRoutesModule(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
import com.linagora.tmail.team.TeamMailboxModule;
import com.linagora.tmail.webadmin.EmailAddressContactRoutesModule;
import com.linagora.tmail.webadmin.OidcBackchannelLogoutRoutesModule;
import com.linagora.tmail.webadmin.RateLimitPlanRoutesModule;
import com.linagora.tmail.webadmin.RateLimitsRoutesModule;
import com.linagora.tmail.webadmin.TeamMailboxRoutesModule;
import com.linagora.tmail.webadmin.archival.InboxArchivalTaskModule;
import com.linagora.tmail.webadmin.cleanup.MailboxesCleanupModule;
Expand Down Expand Up @@ -179,7 +179,7 @@ public class MemoryServer {
new TMailScanningQuotaSearcherModule(),
new MemoryRateLimiterModule(),
new MemoryRateLimitingModule(),
new RateLimitPlanRoutesModule(),
new RateLimitsRoutesModule(),
new MemoryEmailAddressContactModule(),
new EmailAddressContactRoutesModule(),
new MemoryLabelRepositoryModule(),
Expand Down
Loading