-
Notifications
You must be signed in to change notification settings - Fork 64
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
ARXIVCE-2902 use first X-Forwarded-For IP in /institutional_banner #808
Conversation
result = get_institution(request.remote_addr) | ||
forwarded_ips = request.headers.getlist("X-Forwarded-For") | ||
if len(forwarded_ips)>0: | ||
ip = str(forwarded_ips[0]).split(',')[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't the forwarded ips be space-delimited, too?
Do you need code to strip the ip string of leading and trailing spaces?
Do you need more robustness / error checking? What if forwarded_ips is None?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On point 3, I double-checked, .getlist
returns an empty list in the case the header isn't present.
I'll handle some more whitespaces, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. They are defined as comma-separated, so this should handle the specified syntax.
f444a08
to
b6fc06a
Compare
Rebased on develop and ensured type-checking is happy. |
SSIA