Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Send user's IP address with metrics #19

Merged
merged 2 commits into from Mar 17, 2022
Merged

Send user's IP address with metrics #19

merged 2 commits into from Mar 17, 2022

Conversation

ruohola
Copy link
Member

@ruohola ruohola commented Mar 17, 2022

Used for visualization aggregate geolocation data. The IP is never
stored, and it is never sent to 3rd parties.

We read the IP from the X-Forwarded-For header since in production
one's backend service is most likely behind a reverse proxy of some
sort. We use the left-most value in case there are multiple IPs in it,
since that's most likely not from "our" infra and we don't have to worry
about spoofing too much because it's not used for anything security
related.

Some additional reading about getting the real IP address:
https://adam-p.ca/blog/2022/03/x-forwarded-for/

@ruohola ruohola requested a review from blomqma March 17, 2022 19:57
@codecov
Copy link

codecov bot commented Mar 17, 2022

Codecov Report

Merging #19 (5c29d99) into master (dbf8336) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master       #19   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines          127       128    +1     
  Branches        11        11           
=========================================
+ Hits           127       128    +1     
Impacted Files Coverage Δ
apilytics/django.py 100.00% <ø> (ø)
apilytics/fastapi.py 100.00% <ø> (ø)
apilytics/core.py 100.00% <100.00%> (ø)

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@ruohola ruohola force-pushed the send-geo-ip branch 2 times, most recently from 28671c2 to 58ffacd Compare March 17, 2022 20:28
@ruohola ruohola changed the title Send user's IP address with metrics. Send user's IP address with metrics Mar 17, 2022
Used for visualization aggregate geolocation data. The IP is never
stored, and it is never sent to 3rd parties.

We read the IP from the `X-Forwarded-For` header since in production
one's backend service is most likely behind a reverse proxy of some
sort. We use the left-most value in case there are multiple IPs in it,
since that's most likely not from "our" infra and we don't have to worry
about spoofing too much because it's not used for anything security
related.

Some additional reading about getting the real IP address:
https://adam-p.ca/blog/2022/03/x-forwarded-for/
@ruohola ruohola merged commit 8e2ad9f into master Mar 17, 2022
@ruohola ruohola deleted the send-geo-ip branch March 17, 2022 21:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants