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

Add RATELIMIT_IP_META_KEY setting #218

Merged
merged 2 commits into from Jan 25, 2021
Merged

Add RATELIMIT_IP_META_KEY setting #218

merged 2 commits into from Jan 25, 2021

Conversation

jsocol
Copy link
Owner

@jsocol jsocol commented Jan 25, 2021

Per some discussion in #208, and setting up a good place to resolve the issue raised in #209, adds a _get_ip() helper to ratelimit.core, and adds a setting to control the source of truth for the client IP address.

Adds a _get_ip() helper to ratelimit.core that gets the client IP from
REMOTE_ADDR in one place, rather than multiple throughout the file.
@jsocol jsocol force-pushed the get-ip-helper branch 2 times, most recently from 0ebd045 to 0fd3148 Compare January 25, 2021 02:01
The RATELIMIT_IP_META_KEY setting allows the application to control the
source of truth for the client IP address for use with `key='ip'` or
`key='user_or_ip'`. It enables an application to set this in a single
place rather than setting `key='header:x-client-ip'`, which means this
can be controlled for local development. Like other parameters in
django_ratelimit, this setting accepts callables and paths to callables.
@SerhiyRomanov
Copy link

SerhiyRomanov commented Mar 23, 2021

Running the library from the master branch with these changes in production for a month already - everything works perfectly.
I use nginx + gunicorn.

@jsocol
Copy link
Owner Author

jsocol commented Mar 23, 2021

@SerhiyRomanov that's great to hear, thank you! I will try to prioritize getting together a new release

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

Successfully merging this pull request may close these issues.

None yet

2 participants