X-Git-Url: http://xvm.mit.edu/gitweb/invirt/packages/invirt-vnc-server.git/blobdiff_plain/48c35eb9ddfae29d181757b73713d508127faea8..9dad09631ff778a4dbcf174eaf2a2bb364ecb2f6:/python/vnc/extauth.py diff --git a/python/vnc/extauth.py b/python/vnc/extauth.py index a01a858..be19570 100644 --- a/python/vnc/extauth.py +++ b/python/vnc/extauth.py @@ -65,12 +65,11 @@ class VNCAuth(protocol.Protocol): def validateToken(self, token): self.auth_error = "Invalid token" try: - token = base64.urlsafe_b64decode(token) - token = cPickle.loads(token) + (pickled_data, digest) = map(base64.urlsafe_b64decode, token.split(".")) m = hmac.new(getTokenKey(), digestmod=sha) - m.update(token['data']) - if (m.digest() == token['digest']): - data = cPickle.loads(token['data']) + m.update(pickled_data) + if (m.digest() == digest): + data = cPickle.loads(pickled_data) expires = data["expires"] if (time.time() < expires): self.auth = data["user"] @@ -79,7 +78,7 @@ class VNCAuth(protocol.Protocol): self.auth_data = data else: self.auth_error = "Token has expired; please try logging in again" - except (TypeError, cPickle.UnpicklingError): + except (TypeError, ValueError, cPickle.UnpicklingError): self.auth = None print sys.exc_info()