Browse Source

feat(api): rename throttle scopes

Preparing to use the tighter limit also for some read operations.
Nils Wisiol 2 years ago
parent
commit
0f8156d15a
4 changed files with 10 additions and 10 deletions
  1. 3 3
      api/api/settings.py
  2. 2 2
      api/desecapi/views/domains.py
  3. 2 2
      api/desecapi/views/records.py
  4. 3 3
      docs/rate-limits.rst

+ 3 - 3
api/api/settings.py

@@ -109,9 +109,9 @@ REST_FRAMEWORK = {
         'account_management_active': ['3/min'],  # things with side effect, e.g. sending mail or zone creation on signup
         'account_management_passive': ['10/min'],  # things like GET'ing v/* or auth/* URLs, or creating/deleting tokens
         'dyndns': ['1/min'],  # dynDNS updates, domain-scoped; anything above 1/min is a client misconfiguration
-        'dns_api_read': ['10/s', '50/min'],  # DNS API requests that do not involve pdns
-        'dns_api_write_domains': ['10/s', '300/min', '1000/h'],  # domains/ endpoint
-        'dns_api_write_rrsets': ['2/s', '15/min', '100/h', '300/d'],  # rrsets/ endpoint, domain-scoped on the view
+        'dns_api_cheap': ['10/s', '50/min'],  # DNS API requests that do not involve pdns
+        'dns_api_expensive': ['10/s', '300/min', '1000/h'],  # DNS API requests affecting domains as a whole
+        'dns_api_per_domain_expensive': ['2/s', '15/min', '100/h', '300/d'],  # DNS API requests affecting RRset(s) of a single domain
         # UserRateThrottle
         'user': '2000/d',  # hard limit on requests by a) an authenticated user, b) an unauthenticated IP address
     },

+ 2 - 2
api/desecapi/views/domains.py

@@ -38,9 +38,9 @@ class DomainViewSet(
     @property
     def throttle_scope(self):
         return (
-            "dns_api_read"
+            "dns_api_cheap"
             if self.request.method in SAFE_METHODS
-            else "dns_api_write_domains"
+            else "dns_api_expensive"
         )
 
     @property

+ 2 - 2
api/desecapi/views/records.py

@@ -44,9 +44,9 @@ class RRsetView:
     def throttle_scope(self):
         # noinspection PyUnresolvedReferences
         return (
-            "dns_api_read"
+            "dns_api_cheap"
             if self.request.method in SAFE_METHODS
-            else "dns_api_write_rrsets"
+            else "dns_api_per_domain_expensive"
         )
 
     @property

+ 3 - 3
docs/rate-limits.rst

@@ -33,17 +33,17 @@ the API.  When several rates are given, all are enforced at the same time.
 +-----------------------------------------+----------+-------------------------------------------------------------------------------------------+
 | ``dyndns``                              | 1/min    | dynDNS updates (per domain).                                                              |
 +-----------------------------------------+----------+-------------------------------------------------------------------------------------------+
-| ``dns_api_read``                        | 10/s     | DNS read operations (e.g. fetching an RRset)                                              |
+| ``dns_api_cheap``                       | 10/s     | DNS read operations (e.g. fetching an RRset)                                              |
 |                                         |          |                                                                                           |
 |                                         | 50/min   |                                                                                           |
 +-----------------------------------------+----------+-------------------------------------------------------------------------------------------+
-| ``dns_api_write_domains``               | 10/s     | DNS write operations: domain creation/deletion                                            |
+| ``dns_api_expensive``                   | 10/s     | DNS write operations: domain creation/deletion                                            |
 |                                         |          |                                                                                           |
 |                                         | 300/min  |                                                                                           |
 |                                         |          |                                                                                           |
 |                                         | 1000/h   |                                                                                           |
 +-----------------------------------------+----------+-------------------------------------------------------------------------------------------+
-| ``dns_api_write_rrsets``                | 2/s      | DNS write operations: RRset creation/deletion/modification (per domain).  If you require  |
+| ``dns_api_per_domain_expensive``        | 2/s      | RRset creation/deletion/modification (per domain).  If you require                        |
 |                                         |          | more requests, consider using bulk requests.                                              |
 |                                         | 15/min   |                                                                                           |
 |                                         |          |                                                                                           |