Merge lp:~gesha/linaro-license-protection/remove-x-forwarded-for into lp:~linaro-automation/linaro-license-protection/trunk

Proposed by Georgy Redkozubov
Status: Merged
Approved by: Данило Шеган
Approved revision: 125
Merged at revision: 125
Proposed branch: lp:~gesha/linaro-license-protection/remove-x-forwarded-for
Merge into: lp:~linaro-automation/linaro-license-protection/trunk
Diff against target: 37 lines (+1/-17)
2 files modified
license_protected_downloads/tests/test_views.py (+0/-12)
license_protected_downloads/views.py (+1/-5)
To merge this branch: bzr merge lp:~gesha/linaro-license-protection/remove-x-forwarded-for
Reviewer Review Type Date Requested Status
Данило Шеган (community) Approve
Review via email: mp+122021@code.launchpad.net

Description of the change

This branch removes X-FORWARDED-FOR support since it is easy to spoof even with wget.

To post a comment you must log in.
Revision history for this message
Данило Шеган (danilo) wrote :

Looks good, thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'license_protected_downloads/tests/test_views.py'
2--- license_protected_downloads/tests/test_views.py 2012-08-28 17:15:06 +0000
3+++ license_protected_downloads/tests/test_views.py 2012-08-30 10:04:18 +0000
4@@ -353,18 +353,6 @@
5 r'lp:linaro-license-protection</a> r' +
6 str(bzr_version.get_my_bzr_revno())))
7
8- def test_exception_ip_x_forwarded_for(self):
9- internal_host = INTERNAL_HOSTS[0]
10- target_file = 'build-info/origen-blob.txt'
11- url = urlparse.urljoin("http://testserver/", target_file)
12- response = self.client.get(url, follow=True,
13- HTTP_X_FORWARDED_FOR=internal_host)
14-
15- # If we have access to the file, we will get an X-Sendfile response
16- self.assertEqual(response.status_code, 200)
17- file_path = os.path.join(TESTSERVER_ROOT, target_file)
18- self.assertEqual(response['X-Sendfile'], file_path)
19-
20 def test_exception_ip_remote_addr(self):
21 internal_host = INTERNAL_HOSTS[0]
22 target_file = 'build-info/origen-blob.txt'
23
24=== modified file 'license_protected_downloads/views.py'
25--- license_protected_downloads/views.py 2012-08-28 17:15:06 +0000
26+++ license_protected_downloads/views.py 2012-08-30 10:04:18 +0000
27@@ -232,11 +232,7 @@
28
29
30 def get_client_ip(request):
31- x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
32- if x_forwarded_for:
33- ip = x_forwarded_for.split(',')[-1].strip()
34- else:
35- ip = request.META.get('REMOTE_ADDR')
36+ ip = request.META.get('REMOTE_ADDR')
37 return ip
38
39

Subscribers

People subscribed via source and target branches