2015-11-03 59 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