Bird
0
0

You want to limit requests per user instead of per IP address in Flask-Limiter. Which key function should you use?

hard📝 Application Q9 of 15
Flask - Security Best Practices
You want to limit requests per user instead of per IP address in Flask-Limiter. Which key function should you use?
AA custom function that returns the current user's unique ID
Bget_remote_address (default IP-based key function)
CA function that returns a random number each request
DNo key function is needed for user-based limits
Step-by-Step Solution
Solution:
  1. Step 1: Understand key_func role

    key_func returns a string to identify the client for rate limiting.
  2. Step 2: Use user ID for user-based limits

    To limit per user, key_func must return the user's unique ID, not IP.
  3. Final Answer:

    A custom function that returns the current user's unique ID -> Option A
  4. Quick Check:

    User-based limit needs user ID key_func [OK]
Quick Trick: Use user ID in key_func for per-user limits [OK]
Common Mistakes:
MISTAKES
  • Using IP address for user limits
  • Returning random values in key_func
  • Skipping key_func for user limits

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Flask Quizzes