How to use the crossbar._util.hltype function in crossbar

To help you get started, we’ve selected a few crossbar 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 crossbario / crossbar / crossbar / worker / router.py View on Github external
:type authrole: str

        :returns: True if realm is running.
        :rtype: bool
        """
        authrole = authrole or 'trusted'
        result = realm in self.realm_to_id and self.realm_to_id[realm] in self.realms
        if result:
            realm_id = self.realm_to_id[realm]
            result = (authrole in self.realms[realm_id].role_to_id and self.realms[realm_id].role_to_id[authrole] in self.realms[realm_id].roles)

            # note: this is to enable eg built-in "trusted" authrole
            result = result or authrole in self._service_sessions[realm]

        self.log.debug('{func}(realm="{realm}", authrole="{authrole}") -> {result}',
                       func=hltype(RouterController.has_role), realm=hlid(realm), authrole=hlid(authrole),
                       result=hlval(result))
        return result
github crossbario / crossbar / crossbar / worker / proxy.py View on Github external
def get_proxy_routes(self, details=None):
        """
        Get proxy routes currently running in this proxy worker.

        :param details: Call details.
        :type details: :class:`autobahn.wamp.types.CallDetails`

        :returns: List of (target) realm names in proxy routes currently running.
        :rtype: list
        """
        self.log.debug('{func}(details={details})',
                       func=hltype(self.get_proxy_routes),
                       details=details)
        return sorted(self._routes.keys())
github crossbario / crossbar / crossbar / router / auth / cryptosign.py View on Github external
def hello(self, realm: str, details: types.HelloDetails):
        self.log.debug('{func}::hello(realm="{realm}", details.authid="{authid}", details.authrole="{authrole}")',
                       func=hltype(self.hello), realm=hlid(realm), authid=hlid(details.authid),
                       authrole=hlid(details.authrole))

        # the channel binding requested by the client authenticating
        channel_binding = details.authextra.get('channel_binding', None) if details.authextra else None
        if channel_binding is not None and channel_binding not in ['tls-unique']:
            return types.Deny(message='invalid channel binding type "{}" requested'.format(channel_binding))
        else:
            self.log.debug(
                "WAMP-cryptosign CHANNEL BINDING requested: channel_binding={channel_binding}, channel_id={channel_id}",
                channel_binding=channel_binding,
                channel_id=self._channel_id
            )

        # remember the realm the client requested to join (if any)
        self._realm = realm
github crossbario / crossbar / crossbar / worker / router.py View on Github external
def set_service_session(self, session, realm, authrole):
        authrole = authrole or 'trusted'
        if realm not in self._service_sessions:
            self._service_sessions[realm] = {}
        self._service_sessions[realm][authrole] = session
        self.log.info('{func}(session={session}, realm="{realm}", authrole="{authrole}")',
                      func=hltype(self.set_service_session), session=session,
                      realm=hlid(realm), authrole=hlid(authrole))
github crossbario / crossbar / crossbar / worker / proxy.py View on Github external
def has_realm(self, realm: str) -> bool:
        """
        Check if a route to a realm with the given name is currently running.

        :param realm: Realm name (_not_ ID).
        :type realm: str

        :returns: True if a route to the realm exists.
        :rtype: bool
        """
        result = realm in self._routes
        self.log.info('{func}(realm="{realm}") -> {result}', func=hltype(ProxyController.has_realm),
                      realm=hlid(realm), result=hlval(result))
        return result
github crossbario / crossbar / crossbar / worker / router.py View on Github external
"""
        Returns the currently running routing links to remote router realms.

        :param realm_id: The ID of the (local) realm to get links for.
        :type realm_id: str

        :returns: List of router link IDs.
        :rtype: list[str]
        """
        assert type(realm_id) == str
        assert isinstance(details, CallDetails)

        self.log.info(
            'Getting router links for realm {realm_id} {method}',
            realm_id=hlid(realm_id),
            method=hltype(RouterController.get_router_realm_links))

        if realm_id not in self.realms:
            raise ApplicationError("crossbar.error.no_such_object", "No realm with ID '{}'".format(realm_id))

        rlink_manager = self.realms[realm_id].rlink_manager

        return sorted([str(k) for k in rlink_manager.keys()])
github crossbario / crossbar / crossbar / router / session.py View on Github external
def onAuthenticate_error(err):
                    self.log.warn('{func}.onMessage(..)::onAuthenticate(..) failed with {err}',
                                  func=hltype(self.onMessage), err=err)
                    self.log.failure(err)
                    return self._swallow_error_and_abort(err)
github crossbario / crossbar / crossbar / node / node.py View on Github external
def set_service_session(self, session, realm, authrole=None):
        self.log.info('{func}(session={session}, realm="{realm}", authrole="{authrole}")',
                      func=hltype(self.set_service_session), session=session,
                      realm=hlid(realm), authrole=hlid(authrole))
        if realm not in self._service_sessions:
            self._service_sessions[realm] = {}
        self._service_sessions[realm][authrole] = session
github crossbario / crossbar / crossbar / worker / router.py View on Github external
def get_service_session(self, realm, authrole):
        authrole = authrole or 'trusted'
        session = None
        if realm in self._service_sessions:
            if authrole in self._service_sessions[realm]:
                session = self._service_sessions[realm][authrole]
        self.log.debug('{func}(realm="{realm}", authrole="{authrole}") -> {session}',
                       func=hltype(self.get_service_session), session=session,
                       realm=hlid(realm), authrole=hlid(authrole))
        return succeed(session)
github crossbario / crossbar / crossbar / worker / container.py View on Github external
def _ready(s):
                    # this is different from "self.config.controller._realm" !!
                    self.log.info('Container component ready: component_id="{component_id}", realm="{realm}", authrole="{authrole}", authid="{authid}", session={session} {func}',
                                  func=hltype(self.onJoin), component_id=hlid(component_id), realm=hlid(session._realm),
                                  authid=hlid(session._authid), authrole=hlid(session._authrole), session=hlid(session._session_id))
                    if not joined_d.called:
                        joined_d.callback(None)
                session.on('ready', _ready)