-
Notifications
You must be signed in to change notification settings - Fork 1
Description
The code right now chooses the rightmost X-Forwarded-For or Forwarded value. This only works if there is only one reverse proxy.
Instead, AllowedNets could be used to check from the rightmost for the first (from the right) IP that is not in the AllowedNets ranges. This would allow for any number of trusted reverse proxies between the internet and the server using this library.
If you do change to searching from the right, make sure to include all matching headers rather than just the last one. Otherwise you might search through the whole last header without finding what you want, and miss other headers.
More details here: https://adam-p.ca/blog/2022/03/x-forwarded-for/#algorithms
(I applaud you for using a rightmost approach rather than leftmost. This library is better than the vast majority of similar libraries that I looked at.)