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

feat(httpx): use cf-connecting-ip header for client IP #786

Merged
merged 1 commit into from
Jun 24, 2024

Conversation

mfzl
Copy link
Contributor

@mfzl mfzl commented May 22, 2024

Adds Cf-Connecting-IP to the list of headers to check for real client IP. This header is set by Cloudflare to have the real client IP address.

https://developers.cloudflare.com/fundamentals/reference/http-request-headers/#cf-connecting-ip

Since we are already relying on cloudflare headers for device location and how ubiquitous Cloudflare has become it's a good idea to have support for it.

We cannot rely on X-forwarded-for when behind Cloudflare as well, since the order of the IPs listed by Cloudflare is not the order this library checks.

Related Issue or Design Document

Checklist

  • I have read the contributing guidelines and signed the CLA.
  • I have referenced an issue containing the design document if my change introduces a new feature.
  • I have read the security policy.
  • I confirm that this pull request does not address a security vulnerability.
    If this pull request addresses a security vulnerability,
    I confirm that I got approval (please contact security@ory.sh) from the maintainers to push the changes.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added the necessary documentation within the code base (if appropriate).

Further comments

@mfzl
Copy link
Contributor Author

mfzl commented May 22, 2024

I could potentially also "fix" the x-forwarded-for order as well. It looks like a bug after reading this.

It should be the first public IP address going from left-to-right. Right now it's the first public IP address from right-to-left

@aeneasr
Copy link
Member

aeneasr commented Jun 4, 2024

I could potentially also "fix" the x-forwarded-for order as well. It looks like a bug after reading this.

It should be the first public IP address going from left-to-right. Right now it's the first public IP address from right-to-left

Yes please - if there is a bug we appreciate a fix!

auto-merge was automatically disabled June 14, 2024 19:17

Head branch was pushed to by a user without write access

@mfzl
Copy link
Contributor Author

mfzl commented Jun 14, 2024

I could potentially also "fix" the x-forwarded-for order as well. It looks like a bug after reading this.
It should be the first public IP address going from left-to-right. Right now it's the first public IP address from right-to-left

Yes please - if there is a bug we appreciate a fix!

Hey @aeneasr I will raise another PR for that. If you have no objections to the changes to the PR this can be merged and closed

@aeneasr aeneasr merged commit fc48db8 into ory:master Jun 24, 2024
8 checks passed
@aeneasr
Copy link
Member

aeneasr commented Jun 24, 2024

Sounds good!

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.

2 participants