1
0
mirror of https://github.com/Yubico/yubiadmin.git synced 2024-11-29 01:24:12 +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):
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__':
parser = argparse.ArgumentParser(
description="",
@ -69,12 +78,13 @@ if __name__ == '__main__':
static_app = DirectoryApp(static_dir)
validator = StaticPasswordValidator(args.username, args.password)
@wsgify
def with_static(request):
if request.authorization:
_, auth = request.authorization
if base64.b64decode(auth) == '%s:%s' % (args.username,
args.password):
if validator(auth):
base = request.path_info_peek()
if base in STATIC_ASSETS:
return request.get_response(static_app)

View File

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