diff --git a/ecommerce/extensions/api/throttles.py b/ecommerce/extensions/api/throttles.py index 2f8cd236405..c0ed407b649 100644 --- a/ecommerce/extensions/api/throttles.py +++ b/ecommerce/extensions/api/throttles.py @@ -11,7 +11,11 @@ def allow_request(self, request, view): """Returns True if the request is coming from one of the service users and defaults to UserRateThrottle's configured setting otherwise. """ - service_users = [settings.ECOMMERCE_SERVICE_WORKER_USERNAME, settings.PROSPECTUS_WORKER_USERNAME] + service_users = [ + settings.ECOMMERCE_SERVICE_WORKER_USERNAME, + settings.PROSPECTUS_WORKER_USERNAME, + settings.DISCOVERY_SERVICE_WORKER_USERNAME, + ] if request.user.username in service_users: return True return super(ServiceUserThrottle, self).allow_request(request, view) diff --git a/ecommerce/settings/base.py b/ecommerce/settings/base.py index e6e8de633af..7cf90d7a265 100644 --- a/ecommerce/settings/base.py +++ b/ecommerce/settings/base.py @@ -545,6 +545,9 @@ # Service user for worker processes. ECOMMERCE_SERVICE_WORKER_USERNAME = 'ecommerce_worker' +# Service user for Discovery worker processes. +DISCOVERY_SERVICE_WORKER_USERNAME = 'discovery_worker' + # Worker user used by prospectus to query ecommerce PROSPECTUS_WORKER_USERNAME = 'prospectus_worker' @@ -588,7 +591,7 @@ 'DEFAULT_PAGINATION_CLASS': 'ecommerce.extensions.api.pagination.PageNumberPagination', 'PAGE_SIZE': 20, 'DEFAULT_THROTTLE_CLASSES': ( - 'rest_framework.throttling.UserRateThrottle', + 'ecommerce.extensions.api.throttles.ServiceUserThrottle', ), 'DEFAULT_THROTTLE_RATES': { 'user': '75/minute', diff --git a/ecommerce/settings/production.py b/ecommerce/settings/production.py index fef638f8c43..cf772c0ca8d 100644 --- a/ecommerce/settings/production.py +++ b/ecommerce/settings/production.py @@ -148,3 +148,6 @@ def get_env_setting(setting): DCS_SESSION_COOKIE_SAMESITE = config_from_yaml.get('DCS_SESSION_COOKIE_SAMESITE', DCS_SESSION_COOKIE_SAMESITE) DCS_SESSION_COOKIE_SAMESITE_FORCE_ALL = config_from_yaml.get('DCS_SESSION_COOKIE_SAMESITE_FORCE_ALL', DCS_SESSION_COOKIE_SAMESITE_FORCE_ALL) + +# Service user for Discovery worker processes. +DISCOVERY_SERVICE_WORKER_USERNAME = config_from_yaml.get('DISCOVERY_SERVICE_WORKER_USERNAME', DISCOVERY_SERVICE_WORKER_USERNAME)