linagora / tmail-backend

GNU Affero General Public License v3.0
39 stars 21 forks source link

Refactor TMail RateLimiting plan to be applied by domain #458

Open Arsnael opened 2 years ago

Arsnael commented 2 years ago

Today the RateLimiting plan on TMail is assigned individually to each user.

We should refactor that so we can change it to apply a plan to a domain (that will apply for every user belonging to that domain)

For this, we need to :

Attach a plan to a domain:

curl -XPUT http://ip:port/domains/{domain}/rate-limit-plans/{planName}

=> returns:
{"rateLimitPlanName": "XYZ"} 

Get list of domains belonging to a plan:

curl -XGET http://ip:port/rate-limit-plans/{planName}/domains

Get plan belonging to a domain:

curl -XGET http://ip:port/domains/{domain}/rate-limit-plans

Revoke plan of a domain:

curl -XDELETE http://ip:port/domains/{domain}/rate-limit-plans

DoD: unit tests + one integration test to show the routes are correctly bound to TMail

Arsnael commented 2 years ago

I'm not completely sure on this one so don't hesitate to discuss choices here

chibenwa commented 2 years ago

I'm not completely sure on this one so don't hesitate to discuss choices here

IMO one domain should only have a single rate limiting plan. It would make the job of the connector even easier (set the plan of the domain instread of add one, remove one).

Proposal:

curl -XPUT http://ip:port/domains/{domain}/rate-limit-plan

Returns:

{"rateLimitPlanName": "XYZ"}

WDYT?

Arsnael commented 2 years ago

You mean instead of adding first a plan, then binding it to a domain, there would be just one route that would add and bind it to the domain directly correct?

I'm ok with that.

Concerning then the rest:

chibenwa commented 2 years ago

we still need a route to revoke the plan of a domain correct?

Yes.

chibenwa commented 2 years ago
curl -XPOST http://ip:port/domains/{domain}/rate-limit-plan

{
   "rateLimitingPlanName": "payingPlan"
}