diff --git a/doc/release/RELEASE-NOTES.md b/doc/release/RELEASE-NOTES.md index f196f36bb..e2ab6a14e 100644 --- a/doc/release/RELEASE-NOTES.md +++ b/doc/release/RELEASE-NOTES.md @@ -3,6 +3,15 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). The format is based on the `RELEASE-NOTES-TEMPLATE.md` file. +## Release 1.23.0 + +## Introduction +* Product name: Open Supply Hub +* Release date: November 2, 2024 + +### Code/API changes +* Throttling has been introduced for tiles/* endpoints, limiting requests to 300 per minute. + ## Release 1.22.0 ## Introduction diff --git a/src/django/api/throttles.py b/src/django/api/throttles.py index 3a4ef8a63..450609971 100644 --- a/src/django/api/throttles.py +++ b/src/django/api/throttles.py @@ -1,5 +1,6 @@ from django.core.cache import caches from rest_framework.throttling import UserRateThrottle +from rest_framework.throttling import ScopedRateThrottle class UserCustomRateThrottle(UserRateThrottle): @@ -33,3 +34,8 @@ class SustainedRateThrottle(UserCustomRateThrottle): class DataUploadThrottle(UserCustomRateThrottle): scope = 'data_upload' model_rate_field = 'data_upload_rate' + + +class TilesThrottle(ScopedRateThrottle): + scope = 'tiles' + model_rate_field = 'tiles_rate' diff --git a/src/django/api/views/tile/get_tile.py b/src/django/api/views/tile/get_tile.py index e0a9a8312..aedb9a9cb 100644 --- a/src/django/api/views/tile/get_tile.py +++ b/src/django/api/views/tile/get_tile.py @@ -1,3 +1,4 @@ +from api.throttles import TilesThrottle from rest_framework.exceptions import ValidationError from rest_framework.decorators import ( api_view, @@ -26,7 +27,7 @@ @permission_classes([IsAllowedHost]) @renderer_classes([MvtRenderer]) @cache_control(max_age=settings.TILE_CACHE_MAX_AGE_IN_SECONDS) -@throttle_classes([]) +@throttle_classes([TilesThrottle]) @waffle_switch('vector_tile') def get_tile(request, layer, cachekey, z, x, y, ext): if cachekey is None: diff --git a/src/django/oar/settings.py b/src/django/oar/settings.py index 700019890..192658208 100644 --- a/src/django/oar/settings.py +++ b/src/django/oar/settings.py @@ -169,7 +169,8 @@ 'DEFAULT_THROTTLE_RATES': { 'burst': '100/minute', 'sustained': '10000/day', - 'data_upload': '30/minute' + 'data_upload': '30/minute', + 'tiles': '300/minute', } }