Skip to content

Commit

Permalink
Merge pull request #808 from arXiv/institutional-banner-x-forwarded-for
Browse files Browse the repository at this point in the history
ARXIVCE-2902 use first X-Forwarded-For IP in /institutional_banner
  • Loading branch information
cbf66 authored Dec 11, 2024
2 parents c944f13 + 9ed3fe1 commit 99da570
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion browse/routes/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,16 @@ def catchup(subject:str, date:str) -> Response:
@blueprint.route("institutional_banner", methods=["GET"])
def institutional_banner() -> Any:
try:
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]
ip = ip.strip()
elif request.remote_addr is None:
return ("{}", status.OK)
else:
ip = str(request.remote_addr)

result = get_institution(ip)
if result:
return (result, status.OK)
else:
Expand Down

0 comments on commit 99da570

Please sign in to comment.