Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rate limit based on session ID #56

Closed
getub opened this issue Jan 27, 2015 · 3 comments
Closed

Rate limit based on session ID #56

getub opened this issue Jan 27, 2015 · 3 comments

Comments

@getub
Copy link

getub commented Jan 27, 2015

I could not find any discussion in the issues on support of session ID for ratelimiting. Wouldn't it be a more suitable parameter rather than IP address. This would especially be useful for visitors that share a common IP address e.g. a corporation.

@jsocol
Copy link
Owner

jsocol commented Jan 27, 2015

You can write your own method to use the session ID as the ratelimit key. key supports callables and dotted paths to callables.

Ratelimiting by session ID provides too little utility to be in the core.

  • If the user is logged in, you can use the user ID.
  • If the user is not logged in, they can change their session ID at will by erasing or ignoring the cookie.

(Yes, it's possible to spoof IP addresses, but if someone is going to that trouble you have to assume they're willing to ignore session cookies, too.)

I use ratelimit on a site that gets a lot of traffic from schools, who are probably the biggest NAT offenders. This is exactly why ratelimit's default is not to block requests, but to annotate them so you could, e.g., require a captcha. I also mention NAT in the Security Considerations section of the docs.

@jsocol jsocol closed this as completed Jan 27, 2015
@getub
Copy link
Author

getub commented Aug 1, 2015

I use ratelimit on a site that gets a lot of traffic from schools, who are probably the biggest NAT offenders. This is exactly why ratelimit's default is not to block requests, but to annotate them so you could, e.g., require a captcha.

What's your strategy to reset ratelimit after captcha is successful ? A view may have more than one ratelimiters, how do you know which one should be reset after the captcha. 1 way is to put the cache key as a POST parameter, but that can be spoofed with little effort. Any other ideas ?

@jsocol
Copy link
Owner

jsocol commented Aug 7, 2015

Honestly my strategy is to fix #36.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants