Merge lp:~rlane/nova/lp773690 into lp:~hudson-openstack/nova/trunk

Proposed by Ryan Lane
Status: Work in progress
Proposed branch: lp:~rlane/nova/lp773690
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 29 lines (+12/-5)
1 file modified
bin/nova-ajax-console-proxy (+12/-5)
To merge this branch: bzr merge lp:~rlane/nova/lp773690
Reviewer Review Type Date Requested Status
Vish Ishaya (community) Approve
Cory Wright (community) Approve
Review via email: mp+59565@code.launchpad.net

Description of the change

Only uses HTTP_REFERER if HTTP_REFERER has token set. Fix for using ajax console urls in iframes.

To post a comment you must log in.
lp:~rlane/nova/lp773690 updated
406. By Ryan Lane

Only parse url if needed.

407. By Ryan Lane

Ensure the auth_params are set, even if HTTP_REFERER does not contain a token. Also, document why we must do this check.

Revision history for this message
Cory Wright (corywright) wrote :

Straightforward enough. lgtm.

review: Approve
Revision history for this message
Vish Ishaya (vishvananda) wrote :

lgtm as well

review: Approve
Revision history for this message
Vish Ishaya (vishvananda) wrote :

I suppose we should actually require a test for this, although I'm not totally sure there is one that would make sense here. Ryan, do you see a way to write a simple test here?

Revision history for this message
Devin Carlen (devcamcar) wrote :

Setting to work in progress while the testing strategy for this is determined.

Revision history for this message
Ryan Lane (rlane) wrote :

Yes. I can write a test for this.

Unmerged revisions

407. By Ryan Lane

Ensure the auth_params are set, even if HTTP_REFERER does not contain a token. Also, document why we must do this check.

406. By Ryan Lane

Only parse url if needed.

405. By Ryan Lane

Only uses HTTP_REFERER if HTTP_REFERER has token set

404. By Ryan Lane

Merge from trunk

403. By Ryan Lane

Merge from trunk

402. By Ryan Lane

Merge from trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/nova-ajax-console-proxy'
2--- bin/nova-ajax-console-proxy 2011-03-29 23:13:09 +0000
3+++ bin/nova-ajax-console-proxy 2011-05-02 20:31:30 +0000
4@@ -73,13 +73,20 @@
5 env['HTTP_HOST'],
6 env['PATH_INFO'])
7
8+ parsed_url = urlparse.urlparse(req_url)
9+
10+ # If the url is embeded in an iframe, the first HTTP_REFERER
11+ # will very likely not contain the token. In this situation
12+ # we should use the req_url.
13 if 'HTTP_REFERER' in env:
14- auth_url = env['HTTP_REFERER']
15+ refer_params = urlparse.parse_qs(urlparse.urlparse(
16+ env['HTTP_REFERER']).query)
17+ if 'token' in refer_params:
18+ auth_params = refer_params
19+ else:
20+ auth_params = urlparse.parse_qs(parsed_url.query)
21 else:
22- auth_url = req_url
23-
24- auth_params = urlparse.parse_qs(urlparse.urlparse(auth_url).query)
25- parsed_url = urlparse.urlparse(req_url)
26+ auth_params = urlparse.parse_qs(parsed_url.query)
27
28 auth_info = AjaxConsoleProxy.tokens[auth_params['token'][0]]
29 args = auth_info['args']