Skip to content

Commit 0a05469

Browse files
committed
Align auth register throttle scope
1 parent 1793978 commit 0a05469

5 files changed

Lines changed: 6 additions & 5 deletions

File tree

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ EMAIL_PASSWORD=
88
EMAIL_HOST=
99
EMAIL_PORT=
1010

11-
DRF_THROTTLE_AUTH_USER_CREATE=5/min
11+
DRF_THROTTLE_AUTH_REGISTER=5/min
1212
DRF_THROTTLE_AUTH_RESEND_EMAIL=3/min
1313
DRF_THROTTLE_AUTH_RESET_PASSWORD=3/min
1414
DRF_THROTTLE_TOKEN_OBTAIN=10/min

docs/api-safety-fix-plan.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Implemented in this PR:
1212
- `POST /api/token/`
1313
- `POST /programs/<id>/register_new/`
1414
- Added env-configurable rates in `REST_FRAMEWORK["DEFAULT_THROTTLE_RATES"]` without enabling global `DEFAULT_THROTTLE_CLASSES`.
15+
- Scoped rate keys are `auth_register`, `auth_resend_email`, `auth_reset_password`, `token_obtain`, and `program_register_new`.
1516
- Added `.env.example` entries for the new rates.
1617
- Added targeted tests that override each selected scope to `1/min` and assert the second request is throttled.
1718

procollab/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@
164164
"rest_framework.renderers.AdminRenderer",
165165
],
166166
"DEFAULT_THROTTLE_RATES": {
167-
"auth_user_create": config(
168-
"DRF_THROTTLE_AUTH_USER_CREATE", default="5/min", cast=str
167+
"auth_register": config(
168+
"DRF_THROTTLE_AUTH_REGISTER", default="5/min", cast=str
169169
),
170170
"auth_resend_email": config(
171171
"DRF_THROTTLE_AUTH_RESEND_EMAIL", default="3/min", cast=str

users/tests/test_auth_throttling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def setUp(self):
2424
self.client = APIClient()
2525

2626
@override_settings(
27-
REST_FRAMEWORK=throttle_settings(auth_user_create="1/min")
27+
REST_FRAMEWORK=throttle_settings(auth_register="1/min")
2828
)
2929
@patch("users.views.verify_email")
3030
def test_user_registration_post_is_scoped_throttled(self, verify_email_mock):

users/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class UserList(ListCreateAPIView):
8181
filter_backends = (filters.DjangoFilterBackend,)
8282
filterset_class = UserFilter
8383
throttle_classes = [PostOnlyScopedRateThrottle]
84-
throttle_scope = "auth_user_create"
84+
throttle_scope = "auth_register"
8585

8686
def get_permissions(self):
8787
if self.request.method == "POST":

0 commit comments

Comments
 (0)