def handle_client(settings, args): from u2fval.client.controller import ClientController session = create_session(settings, args.debug) controller = ClientController(session) cmd = args.action if cmd == 'list': for client in controller.list_clients(): print(client) else: try: if cmd == 'create': controller.create_client(args.name, args.appId, args.facets) print('Created client: %s' % args.name) elif cmd == 'show': client = controller.get_client(args.name) print('Client: %s' % client.name) print('AppID: %s' % client.app_id) print('FacetIDs:') for facet in client.valid_facets: print(' %s' % facet) elif cmd == 'update': controller.update_client(args.name, args.appId, args.facets) print('Updated client: %s' % args.name) elif cmd == 'delete': controller.delete_client(args.name) print('Deleted client: %s' % args.name) session.commit() except Exception as e: print(e) if args.debug: raise e sys.exit(1)
def handle_client(settings, args): from u2fval.client.controller import ClientController session = create_session(settings, args.debug) controller = ClientController(session) cmd = args.action if cmd == "list": for client in controller.list_clients(): print client else: try: if cmd == "create": controller.create_client(args.name, args.appId, args.facets) print "Created client: %s" % args.name elif cmd == "show": client = controller.get_client(args.name) print "Client: %s" % client.name print "AppID: %s" % client.app_id print "FacetIDs:" for facet in client.valid_facets: print " %s" % facet elif cmd == "update": controller.update_client(args.name, args.appId, args.facets) print "Updated client: %s" % args.name elif cmd == "delete": controller.delete_client(args.name) print "Deleted client: %s" % args.name session.commit() except Exception as e: print e if args.debug: raise e sys.exit(1)
def handle_run(settings, args): from u2fval.core.api import create_application from u2fval.client.pathinfo_auth import client_from_pathinfo from u2fval.client.controller import ClientController from wsgiref.simple_server import make_server extra_environ = {} if args.client: # Ensure the existance of the client. session = create_session(settings, args.debug) controller = ClientController(session) controller.get_client(args.client) session.close() print("Running in single-client mode for client: '%s'" % args.client) extra_environ['REMOTE_USER'] = args.client application = create_application(settings) else: application = client_from_pathinfo(create_application(settings)) httpd = make_server(args.interface, args.port, application) httpd.base_environ.update(extra_environ) print("Starting server on http://%s:%d..." % (args.interface, args.port)) httpd.serve_forever()