How to use the websockify.token_plugins function in websockify

To help you get started, we’ve selected a few websockify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github novnc / websockify / tests / test_websocketproxy.py View on Github external
def test_symmetric_jws_token_plugin(self):
            secret = open("./tests/fixtures/symmetric.key").read()
            key = jwt.JWK()
            key.import_key(kty="oct",k=secret)
            jwt_token = jwt.JWT({"alg": "HS256"}, {'host': "remote_host", 'port': "remote_port"})
            jwt_token.make_signed_token(key)
            self.handler.path = "https://localhost:6080/websockify?token={jwt_token}".format(jwt_token=jwt_token.serialize())

            self.stubs.Set(websocketproxy.ProxyRequestHandler, 'send_auth_error',
                        staticmethod(lambda *args, **kwargs: None))

            self.handler.server.token_plugin = token_plugins.JWTTokenApi("./tests/fixtures/symmetric.key")
            self.handler.validate_connection()

            self.assertEqual(self.handler.server.target_host, "remote_host")
            self.assertEqual(self.handler.server.target_port, "remote_port")
github novnc / websockify / tests / test_websocketproxy.py View on Github external
def test_get_target_raises_error_on_unknown_token(self):
        class TestPlugin(token_plugins.BasePlugin):
            def lookup(self, token):
                return None

        self.assertRaises(FakeServer.EClose, self.handler.get_target,
            TestPlugin(None))
github novnc / websockify / tests / test_websocketproxy.py View on Github external
def test_get_target(self):
        class TestPlugin(token_plugins.BasePlugin):
            def lookup(self, token):
                return ("some host", "some port")

        host, port = self.handler.get_target(
            TestPlugin(None))

        self.assertEqual(host, "some host")
        self.assertEqual(port, "some port")
github oVirt / ovirt-engine / packaging / services / ovirt-websocket-proxy / ovirt-websocket-proxy.py View on Github external
def websockify_has_plugins():
    try:
        import websockify.token_plugins as imported
        wstokens = imported
    except ImportError:
        wstokens = None
    return wstokens is not None