1
0
mirror of https://github.com/Yubico/yubiadmin.git synced 2025-02-20 14:54:30 +01:00

Sys panel fixes.

This commit is contained in:
Dain Nilsson 2013-09-02 11:17:33 +02:00
parent 38afc25abd
commit f5bba0081f
2 changed files with 15 additions and 4 deletions

View File

@ -44,6 +44,15 @@ class CustomRequestHandler(WSGIRequestHandler):
def address_string(self): def address_string(self):
return str(self.client_address[0]) return str(self.client_address[0])
class StaticPasswordValidator(object):
def __init__(self, username, password):
self.auth = base64.b64encode('%s:%s' % (username, password))
def __call__(self, auth):
return self.auth == auth
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description="", description="",
@ -69,12 +78,13 @@ if __name__ == '__main__':
static_app = DirectoryApp(static_dir) static_app = DirectoryApp(static_dir)
validator = StaticPasswordValidator(args.username, args.password)
@wsgify @wsgify
def with_static(request): def with_static(request):
if request.authorization: if request.authorization:
_, auth = request.authorization _, auth = request.authorization
if base64.b64decode(auth) == '%s:%s' % (args.username, if validator(auth):
args.password):
base = request.path_info_peek() base = request.path_info_peek()
if base in STATIC_ASSETS: if base in STATIC_ASSETS:
return request.get_response(static_app) return request.get_response(static_app)

View File

@ -118,12 +118,13 @@ class SystemApp(App):
'info' 'info'
) )
_, time = run('date "+%a, %d %b %Y %H:%M"')
_, result = run('uptime') _, result = run('uptime')
time, rest = [x.strip() for x in result.split('up', 1)] rest = [x.strip() for x in result.split('up', 1)][1]
parts = [x.strip() for x in rest.split(',')] parts = [x.strip() for x in rest.split(',')]
uptime = parts[0] if not 'days' in parts[0] else '%s, %s' % \ uptime = parts[0] if not 'days' in parts[0] else '%s, %s' % \
tuple(parts[:2]) tuple(parts[:2])
yield panel('System', 'System time: %s<br />Uptime: %s' % yield panel('System', 'Date: %s<br />Uptime: %s' %
(time, uptime), level='info') (time, uptime), level='info')
def general(self, request): def general(self, request):