Skip to content

Allow Throttle's IP Address resolver to be a configurable callable #1674

@OscarVanL

Description

@OscarVanL

Is your feature request related to a problem? Please describe.
Due to my loadbalancer configuration, I have an application-specific way I need to get my client's IP address.

The existing Ninja implementation assumes the X-Forwarded-For or ip_addr fields are suitable, but they are not in my specific scenario.

This logic is hardcoded inside get_ident, so not easily customisable in my case.

Describe the solution you'd like
I already use the django-axes package for rate limiting logins on my non-Ninja app. This works great for my needs, because it has a setting AXES_CLIENT_IP_CALLABLE, which I can set to a function with signature def get_client_ip(request: HttpRequest) -> str:.

This allows me to add my app-specific IP resolution logic.

It would be great if Ninja's throttle feature had similar optional customisability.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions