Skip to content

user.throttles ​

Overview ​

Rate limits for VUEDA's auth endpoints.

Classes ​

throttle_code_send ​

Count one code sent to user by method. Raise Throttled when a rate that applies is used up.

The totp_send_user rate counts the codes sent for one account by one method, email or sms. Each method has its own count, so a user who uses up their SMS codes can still get one by email.

Pass destination when the caller chose it, as when setting up a device. The totp_send_destination rate then also counts the codes sent to that email address or phone number across all accounts, so one address cannot be flooded from many accounts. A registered device's destination is left out, because its own user's rate covers it. Counting it across accounts would let anyone use up another user's sign-in codes by sending setup codes to their address.

A refused send counts toward no rate. Throttled makes DRF answer 429 with a Retry-After header. Call this right before sending, after every other check has passed.

Signature ​

throttle_code_send(request, user, method, destination)

Parameters ​

NameTypeRequiredDefaultDescription
requestyes
useryes
methodyes
destinationnoNone

Source ​

server/vueda/user/throttles.py:69

Source ​

server/vueda/user/throttles.py