2015-11-03 41 views
0

我正在使用交叉开关0.11.1,我想让高速公路组件使用特定角色。当我添加了一个“角色”属性来我的组件,如下图所示:如何在Autobahn中设置组件角色

"components": [ 
     { 
      "type": "class", 
      "classname": "hello.hello.AppSession", 
      "realm": "realm1", 
      "role": "anonymous", 
      "transport": { 
       "type": "websocket", 
       "endpoint": { 
       "type": "tcp", 
       "host": "127.0.0.1", 
       "port": 8080 
       }, 
       "url": "ws://127.0.0.1:8080/ws" 
      } 
     } 
    ] 

我跑的时候crossbar start

2015-11-03T10:51:02-0600 [Controller 20933] Automatically choosing optimal Twisted reactor 
2015-11-03T10:51:02-0600 [Controller 20933] Running on Linux and optimal reactor (epoll) was installed. 
2015-11-03T10:51:02-0600 [Controller 20933]  __ __ __ __ __ __  __  __ 
2015-11-03T10:51:02-0600 [Controller 20933] /`|__)/ \/__`/__`|__) /\ |__) |/ \ 
2015-11-03T10:51:02-0600 [Controller 20933]  \__,| \\__/.__/.__/|__)/~~\| \. |\__/ 
2015-11-03T10:51:02-0600 [Controller 20933]           
2015-11-03T10:51:02-0600 [Controller 20933]  Version: 0.11.1  
2015-11-03T10:51:02-0600 [Controller 20933] 
2015-11-03T10:51:02-0600 [Controller 20933] Starting from node directory /home/jaime/code/pubsub/tmp/.crossbar 
2015-11-03T10:51:02-0600 [Controller 20933] Loading node configuration file '/home/jaime/code/pubsub/tmp/.crossbar/config.json' 
2015-11-03T10:51:02-0600 [Controller 20933] *** Configuration validation failed *** 
2015-11-03T10:51:02-0600 [Controller 20933] invalid component configuration - encountered unknown attribute 'role' 

回答

0

您只能以这种方式为“in-router”组件(即“router”类型的worker中的“components”列表)分配角色 - 它们实际上没有传输方式,例如它们与路由器工作人员在同一个Python进程中运行。

对于所有其他组件,它们的角色通过它们连接到的传输的身份验证进行分配。因此,在您的上述情况下,您应该在您在ws://127.0.0.1:8080/ws定义的websocket传输中添加一个“匿名”用户。

对于非匿名的东西,你设置的身份验证机制之一(例如WAMP-CRA),然后你的组件会做这样的事情:在onConnectself.join(u'admin_realm', [u'wampcra'], u'admin'),并使用自己的秘密,按照该文档计算在onChallenge挑战:http://crossbar.io/docs/WAMP-CRA-Authentication/#python-frontend

在路由器端,WAMP-CRA最简单的方法是使用静态凭据,您只需在config.json文件中使用用户密钥。你可以定义一个动态的WAMP-CRA验证码

+0

我可能不得不试试这个。我可以发誓我看到一个允许这个地方的例子,但它可能已经老了。配置文件有时会让我感到困惑。谢谢! – jaime

+0

@jaime如果你*被文档弄糊涂了,那么提交一个描述什么是混淆的bug(对https://github.com/crossbario/crossbar)会是非常有帮助的。越多的人进入一个项目,看到新人被挂断的地方变得越难......:/ – meejah