def add_role(self, realm: str, config: Dict[str, Any]) -> RouterRole: """ Add a role to a realm. :param realm: The name of the realm to add the role to. :param config: The role configuration. :return: The new role object. """ self.log.info('{func}: realm="{realm}", config=\n{config}', func=hltype(self.add_role), realm=hlval(realm), config=pformat(config)) if realm not in self._routers: raise RuntimeError( 'no router started for realm "{}"'.format(realm)) router = self._routers[realm] uri = config['name'] role: RouterRole if 'permissions' in config: role = RouterRoleStaticAuth(router, uri, config['permissions']) elif 'authorizer' in config: role = RouterRoleDynamicAuth(router, uri, config['authorizer']) else: allow_by_default = config.get('allow-by-default', False) role = RouterRole(router, uri, allow_by_default=allow_by_default) router.add_role(role) return role
def add_role(self, realm, config): self.log.debug("CrossbarRouterFactory.add_role(realm = {realm}, config = {config})", realm=realm, config=config) assert(realm in self._routers) router = self._routers[realm] uri = config['name'] if 'permissions' in config: role = RouterRoleStaticAuth(router, uri, config['permissions']) elif 'authorizer' in config: role = RouterRoleDynamicAuth(router, uri, config['authorizer']) else: role = RouterRole(router, uri) router.add_role(role)
def add_role(self, realm, config): self.log.debug("CrossbarRouterFactory.add_role(realm = {realm}, config = {config})", realm=realm, config=config) assert(type(realm) == six.text_type) assert(realm in self._routers) router = self._routers[realm] uri = config[u'name'] if u'permissions' in config: role = RouterRoleStaticAuth(router, uri, config[u'permissions']) elif u'authorizer' in config: role = RouterRoleDynamicAuth(router, uri, config[u'authorizer']) else: allow_by_default = config.get(u'allow-by-default', False) role = RouterRole(router, uri, allow_by_default=allow_by_default) router.add_role(role)