Example #1
0
    def onOpen(self, transport):
        """
        Implements :func:`autobahn.wamp.interfaces.ITransportHandler.onOpen`
        """
        # this is a WAMP transport instance
        self._transport = transport

        # WampLongPollResourceSession instance has no attribute '_transport_info'
        if not hasattr(self._transport, '_transport_info'):
            self._transport._transport_info = {}

        # transport configuration
        if hasattr(self._transport, 'factory') and hasattr(self._transport.factory, '_config'):
            self._transport_config = self._transport.factory._config
        else:
            self._transport_config = {}

        # a dict with x509 TLS client certificate information (if the client provided a cert)
        # constructed from information from the Twisted stream transport underlying the WAMP transport
        client_cert = None
        # eg LongPoll transports lack underlying Twisted stream transport, since LongPoll is
        # implemented at the Twisted Web layer. But we should nevertheless be able to
        # extract the HTTP client cert! <= FIXME
        if hasattr(self._transport, 'transport'):
            client_cert = extract_peer_certificate(self._transport.transport)
        if client_cert:
            self._transport._transport_info[u'client_cert'] = client_cert
            self.log.debug("Client connecting with TLS certificate {client_cert}", client_cert=client_cert)

        # forward the transport channel ID (if any) on transport details
        channel_id = None
        if hasattr(self._transport, 'get_channel_id'):
            # channel ID isn't implemented for LongPolL!
            channel_id = self._transport.get_channel_id()
        if channel_id:
            self._transport._transport_info[u'channel_id'] = binascii.b2a_hex(channel_id).decode('ascii')

        self.log.debug("Client session connected - transport: {transport_info}", transport_info=self._transport._transport_info)

        # basic session information
        self._pending_session_id = None
        self._realm = None
        self._session_id = None
        self._session_roles = None
        self._session_details = None

        # session authentication information
        self._pending_auth = None
        self._authid = None
        self._authrole = None
        self._authmethod = None
        self._authprovider = None
        self._authextra = None

        # the service session to be used eg for WAMP metaevents
        self._service_session = None
Example #2
0
    def onOpen(self, transport):
        """
        Callback fired when transport is open. May run asynchronously. The transport
        is considered running and is_open() would return true, as soon as this callback
        has completed successfully.

        :param transport: The WAMP transport.
        :type transport: object implementing :class:`autobahn.wamp.interfaces.ITransport`
        """
        self.log.info('{klass}.onOpen(transport={transport})', klass=self.__class__.__name__, transport=transport)
        self.transport = transport

        # transport configuration
        if hasattr(self.transport, 'factory') and hasattr(self.transport.factory, '_config'):
            self._transport_config = self.transport.factory._config
        else:
            self._transport_config = {}

        # a dict with x509 TLS client certificate information (if the client provided a cert)
        # constructed from information from the Twisted stream transport underlying the WAMP transport
        client_cert = None
        # eg LongPoll transports lack underlying Twisted stream transport, since LongPoll is
        # implemented at the Twisted Web layer. But we should nevertheless be able to
        # extract the HTTP client cert! <= FIXME
        if hasattr(self.transport, 'transport'):
            client_cert = extract_peer_certificate(self.transport.transport)
        if client_cert:
            self.transport._transport_info['client_cert'] = client_cert
            self.log.info("Proxy frontend session connecting with TLS client certificate {client_cert}",
                          client_cert=client_cert)

        # forward the transport channel ID (if any) on transport details
        channel_id = None
        if hasattr(self.transport, 'get_channel_id'):
            # channel ID isn't implemented for LongPolL!
            channel_id = self.transport.get_channel_id()
        if channel_id:
            self.transport._transport_info['channel_id'] = binascii.b2a_hex(channel_id).decode('ascii')

        self._custom_authextra = {
            'x_cb_proxy_node': self._router_factory._node_id,
            'x_cb_proxy_worker': self._router_factory._worker_id,
            'x_cb_proxy_peer': str(self.transport.peer),
            'x_cb_proxy_pid': os.getpid(),
        }

        self.log.info("Proxy frontend session connected - transport: {transport_info}",
                      transport_info=self.transport._transport_info)
Example #3
0
    def onOpen(self, transport):
        """
        Implements :func:`autobahn.wamp.interfaces.ITransportHandler.onOpen`
        """
        # this is a WAMP transport instance
        self._transport = transport

        # WampLongPollResourceSession instance has no attribute '_transport_info'
        if not hasattr(self._transport, '_transport_info'):
            self._transport._transport_info = {}

        # transport configuration
        if hasattr(self._transport, 'factory') and hasattr(
                self._transport.factory, '_config'):
            self._transport_config = self._transport.factory._config
        else:
            self._transport_config = {}

        # a dict with x509 TLS client certificate information (if the client provided a cert)
        # constructed from information from the Twisted stream transport underlying the WAMP transport
        client_cert = None
        # eg LongPoll transports lack underlying Twisted stream transport, since LongPoll is
        # implemented at the Twisted Web layer. But we should nevertheless be able to
        # extract the HTTP client cert! <= FIXME
        if hasattr(self._transport, 'transport'):
            client_cert = extract_peer_certificate(self._transport.transport)
        if client_cert:
            self._transport._transport_info[u'client_cert'] = client_cert
            self.log.debug(
                "Client connecting with TLS certificate {client_cert}",
                client_cert=client_cert)

        # forward the transport channel ID (if any) on transport details
        channel_id = None
        if hasattr(self._transport, 'get_channel_id'):
            # channel ID isn't implemented for LongPolL!
            channel_id = self._transport.get_channel_id()
        if channel_id:
            self._transport._transport_info[u'channel_id'] = binascii.b2a_hex(
                channel_id).decode('ascii')

        self.log.debug(
            "Client session connected - transport: {transport_info}",
            transport_info=self._transport._transport_info)

        # basic session information
        self._pending_session_id = None
        self._realm = None
        self._session_id = None
        self._session_roles = None
        self._session_details = None

        # session authentication information
        self._pending_auth = None
        self._authid = None
        self._authrole = None
        self._authmethod = None
        self._authprovider = None
        self._authextra = None

        # the service session to be used eg for WAMP metaevents
        self._service_session = None