comparison web/templog.py @ 291:f7261dd970da

- replace ssl client certs with cookies - remove unused ssh code - add /set?fake=1 test mode
author Matt Johnston <matt@ucc.asn.au>
date Sat, 06 Jul 2019 16:32:16 +0800
parents 6c14e0573f50
children 6bacd8ca9f8f
comparison
equal deleted inserted replaced
290:35ae717d48f0 291:f7261dd970da
67 minutes, endstr = get_request_zoom() 67 minutes, endstr = get_request_zoom()
68 return make_graph(minutes, endstr) 68 return make_graph(minutes, endstr)
69 69
70 @route('/set/update', method='post') 70 @route('/set/update', method='post')
71 def set_update(): 71 def set_update():
72 if not secure.check_user_hash(config.ALLOWED_USERS): 72 if not secure.check_cookie(config.ALLOWED_USERS):
73 # the "Save" button should be disabled if the cert wasn't 73 # the "Save" button should be disabled if the cert wasn't
74 # good 74 # good
75 response.status = 403 75 response.status = 403
76 return "No cert, dodginess" 76 return "No cert, dodginess"
77 77
90 90
91 return "Good" 91 return "Good"
92 92
93 @route('/set') 93 @route('/set')
94 def set(): 94 def set():
95 allowed = ["false", "true"][secure.check_user_hash(config.ALLOWED_USERS)] 95 cookie_hash = secure.init_cookie()
96 allowed = ["false", "true"][secure.check_cookie(config.ALLOWED_USERS)]
96 response.set_header('Cache-Control', 'no-cache') 97 response.set_header('Cache-Control', 'no-cache')
97 inline_data = log.get_params() 98 if request.query.fake:
99 inline_data = log.fake_params()
100 else:
101 inline_data = log.get_params()
98 if not inline_data: 102 if not inline_data:
99 response.status = 503 # Service Unavailable 103 response.status = 503 # Service Unavailable
100 return bottle.template('noparamsyet') 104 return bottle.template('noparamsyet')
101 105
102 return bottle.template('set', 106 return bottle.template('set',
103 inline_data = inline_data, 107 inline_data = inline_data,
104 csrf_blob = secure.get_csrf_blob(), 108 csrf_blob = secure.get_csrf_blob(),
105 allowed = allowed) 109 allowed = allowed,
110 cookie_hash = cookie_hash,
111 email = urllib.quote(config.EMAIL))
106 112
107 def get_request_zoom(): 113 def get_request_zoom():
108 """ returns (length, end) tuple. 114 """ returns (length, end) tuple.
109 length is in minutes, end is a DATE_FORMAT string """ 115 length is in minutes, end is a DATE_FORMAT string """
110 minutes = int(request.query.get('length', 26*60)) 116 minutes = int(request.query.get('length', 26*60))