def upgrade(self, **kwargs): try: kwargs["handler_cls"].check_authentication() except: raise cherrypy.HTTPError(401, "You must be logged in to establish a websocket connection.") else: return WebSocketTool.upgrade(self, **kwargs)
def upgrade(self, **kwargs): try: kwargs['handler_cls'].check_authentication() except: raise cherrypy.HTTPError( 401, 'You must be logged in to establish a websocket connection.') else: return WebSocketTool.upgrade(self, **kwargs)
def upgrade(self, **kwargs): try: kwargs['handler_cls'].check_authentication() except WebSocketAuthError: raise cherrypy.HTTPError(401, 'You must be logged in to establish a websocket connection.') except: log.error('unexpected websocket authentication error', exc_info=True) raise cherrypy.HTTPError(401, 'unexpected authentication error') else: return WebSocketTool.upgrade(self, **kwargs)
def upgrade(self, **kwargs): try: kwargs['handler_cls'].check_authentication() except WebSocketAuthError: raise cherrypy.HTTPError( 401, 'You must be logged in to establish a websocket connection.') except: log.error('unexpected websocket authentication error', exc_info=True) raise cherrypy.HTTPError(401, 'unexpected authentication error') else: return WebSocketTool.upgrade(self, **kwargs)
def upgrade(self, protocols=None, extensions=None, version=WS_VERSION, handler_cls=WebSocket, heartbeat_freq=None): _ = protocols # ws4py doesn't support protocols the way we like (using them for authentication) request = cherrypy.serving.request allowed_protocols = [] requested_protocols = request.headers.get('Sec-WebSocket-Protocol') if requested_protocols: for protocol in requested_protocols.split(','): protocol = protocol.strip() if 'authorization.bearer.' in protocol: allowed_protocols.append(protocol) return WebSocketTool.upgrade(self, protocols=allowed_protocols, extensions=extensions, version=version, handler_cls=handler_cls, heartbeat_freq=heartbeat_freq)