- Timestamp:
- Mar 28, 2008, 8:29:04 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/sipb-xen-vnc-server/code/vncexternalauth.py
r125 r288 46 46 47 47 def dataReceived(self,data): 48 #self.socks.log(self,"R"+data) 48 49 self.socks.write(data) 49 50 50 51 def write(self,data): 51 #self.socks.log(self, data)52 #self.socks.log(self,'W'+data) 52 53 self.transport.write(data) 53 54 … … 66 67 def validateToken(self, token): 67 68 global TOKEN_KEY 69 self.auth_error = "Invalid token" 68 70 try: 69 71 token = base64.urlsafe_b64decode(token) … … 71 73 m = hmac.new(TOKEN_KEY, digestmod=sha) 72 74 m.update(token['data']) 73 self.auth_error = "Invalid token"74 75 if (m.digest() == token['digest']): 75 76 data = cPickle.loads(token['data']) … … 82 83 else: 83 84 self.auth_error = "Token has expired; please try logging in again" 84 except :85 self.auth = None 85 except (TypeError, cPickle.UnpicklingError): 86 self.auth = None 86 87 print sys.exc_info() 87 88 … … 100 101 (header, data) = line.split(": ", 1) 101 102 headers[header] = data 102 except :103 except ValueError: 103 104 pass 104 105 … … 115 116 if ("Auth-token" in headers): 116 117 token = headers["Auth-token"] 117 try: 118 self.validateToken(token) 119 finally: 120 if self.auth is not None: 121 port = getPort(vmname, self.auth_data) 122 if port is not None: # FIXME 123 if port is not 0: 124 d = self.connectClass(self.server, port, VNCAuthOutgoing, self) 125 d.addErrback(lambda result, self=self: self.makeReply(404, result.getErrorMessage())) 126 else: 127 self.makeReply(404, "Unable to find VNC for VM "+vmname) 118 self.validateToken(token) 119 if self.auth is not None: 120 port = getPort(vmname, self.auth_data) 121 if port is not None: # FIXME 122 if port != 0: 123 d = self.connectClass(self.server, port, VNCAuthOutgoing, self) 124 d.addErrback(lambda result, self=self: self.makeReply(404, result.getErrorMessage())) 128 125 else: 129 self.makeReply(40 1, "Unauthorized to connect toVM "+vmname)126 self.makeReply(404, "Unable to find VNC for VM "+vmname) 130 127 else: 131 if self.auth_error: 132 self.makeReply(401, self.auth_error) 133 else: 134 self.makeReply(401, "Invalid token") 128 self.makeReply(401, "Unauthorized to connect to VM "+vmname) 129 else: 130 if self.auth_error: 131 self.makeReply(401, self.auth_error) 132 else: 133 self.makeReply(401, "Invalid token") 135 134 else: 136 135 self.makeReply(401, "Login first")
Note: See TracChangeset
for help on using the changeset viewer.