In the web interface, get the VNC auth token over remctl
[invirt/packages/invirt-web.git] / code / main.py
index e4727a8..cfcbd5d 100755 (executable)
@@ -245,18 +245,7 @@ def vnc(username, state, path, fields):
     """
     machine = validation.Validate(username, state, machine_id=fields.getfirst('machine_id')).machine
 
-    TOKEN_KEY = "0M6W0U1IXexThi5idy8mnkqPKEq1LtEnlK/pZSn0cDrN"
-
-    data = {}
-    data["user"] = username
-    data["machine"] = machine.name
-    data["expires"] = time.time()+(5*60)
-    pickled_data = cPickle.dumps(data)
-    m = hmac.new(TOKEN_KEY, digestmod=sha)
-    m.update(pickled_data)
-    token = {'data': pickled_data, 'digest': m.digest()}
-    token = cPickle.dumps(token)
-    token = base64.urlsafe_b64encode(token)
+    token = remctl('control', machine.name, 'vnctoken')
     host = controls.listHost(machine)
     if host:
         port = 10003 + [h.hostname for h in config.hosts].index(host)