Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: sitescripts/testpages/web/sitekey_frame.py

Issue 30011569: Issue 7290 - Fix signature production in sitekey_frame.py (Closed) Base URL: https://hg.adblockplus.org/sitescripts
Patch Set: Initial patch Created Feb. 19, 2019, 10:22 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 # This file is part of the Adblock Plus web scripts, 1 # This file is part of the Adblock Plus web scripts,
2 # Copyright (C) 2006-present eyeo GmbH 2 # Copyright (C) 2006-present eyeo GmbH
3 # 3 #
4 # Adblock Plus is free software: you can redistribute it and/or modify 4 # Adblock Plus is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 3 as 5 # it under the terms of the GNU General Public License version 3 as
6 # published by the Free Software Foundation. 6 # published by the Free Software Foundation.
7 # 7 #
8 # Adblock Plus is distributed in the hope that it will be useful, 8 # Adblock Plus is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
(...skipping 10 matching lines...) Expand all
21 from sitescripts.web import url_handler, request_path 21 from sitescripts.web import url_handler, request_path
22 22
23 23
24 @url_handler('/sitekey-frame') 24 @url_handler('/sitekey-frame')
25 def sitekey_frame(environ, start_response): 25 def sitekey_frame(environ, start_response):
26 template_path, template_file = os.path.split( 26 template_path, template_file = os.path.split(
27 get_config().get('testpages', 'sitekeyFrameTemplate'), 27 get_config().get('testpages', 'sitekeyFrameTemplate'),
28 ) 28 )
29 template = get_template(template_file, template_path=template_path) 29 template = get_template(template_file, template_path=template_path)
30 30
31 http_path = request_path(environ)
32 http_host = environ['HTTP_HOST']
33 http_ua = environ['HTTP_USER_AGENT']
34
31 key = M2Crypto.EVP.load_key(get_config().get('testpages', 'sitekeyPath')) 35 key = M2Crypto.EVP.load_key(get_config().get('testpages', 'sitekeyPath'))
32 key.sign_init() 36 key.sign_init()
33 key.sign_update('\x00'.join(( 37 key.sign_update('\x00'.join([http_path, http_host, http_ua]))
34 request_path(environ),
35 environ['HTTP_HOST'],
36 environ['HTTP_USER_AGENT'],
37 )))
38
39 public_key = base64.b64encode(key.as_der()) 38 public_key = base64.b64encode(key.as_der())
40 signature = base64.b64encode(key.final()) 39 signature = base64.b64encode(key.final())
41 40
42 start_response('200 OK', 41 start_response('200 OK', [
43 [('Content-Type', 'text/html; charset=utf-8'), 42 ('Content-Type', 'text/html; charset=utf-8'),
44 ('X-Adblock-Key', '%s_%s' % (public_key, signature))]) 43 ('X-Adblock-Key', '%s_%s' % (public_key, signature)),
45 return [template.render({'public_key': public_key, 44 ])
46 'signature': signature}).encode('utf-8')] 45 return [template.render({
46 'public_key': public_key,
47 'signature': signature,
48 'http_path': http_path,
Vasily Kuznetsov 2019/02/19 22:28:53 I pass these variables to the template as well so
49 'http_host': http_host,
50 'http_ua': http_ua,
51 }).encode('utf-8')]
OLDNEW

Powered by Google App Engine
This is Rietveld