Skip to content
This repository has been archived by the owner on May 6, 2020. It is now read-only.

Identity ClientIP Including Port #26

Open
jamescoverdale opened this issue Nov 4, 2019 · 0 comments
Open

Identity ClientIP Including Port #26

jamescoverdale opened this issue Nov 4, 2019 · 0 comments

Comments

@jamescoverdale
Copy link

It seems the SetIdentity method includes the port that the client has made the request from. So the ClientIP would look like this 192.168.1.1:32456. This port will change with different requests, especially when requests are coming from scrapers/spiders. This means the request gets a different identity key so previous requests are ignored, meaning the rate limit isn’t applied.

There may be a more obvious way to fix this issue? But my solution was to add the following to my custom filter implementation.

protected override RequestIdentity SetIdentity(HttpRequestBase request)
 {
            var identity = base.SetIdentity(request);
            identity.ClientIp = identity.ClientIp.Substring(0, identity.ClientIp.LastIndexOf(":"));

            return identity;
 }
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant