0

I'm using crossbar 0.11.1 and I want to have an autobahn component use a specific role. When I add a "role" attribute to my component, like below:

"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"
           }
        }
     ]

I get this error when running 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'
jaime
  • 2,234
  • 1
  • 19
  • 22

2 Answers2

1

You may only assign the role in that way for "in-router" components (that is, the "components" list inside a worker of type "router") -- they don't really have a transport, as they're running in the same Python process as the router worker.

For all other components, their role is assigned via the authentication for the transport they connect to. So, in your above case, you'd add an "anonymous" user that has "anonymous" role on the websocket transport you've defined at ws://127.0.0.1:8080/ws.

For non-anonymous things, you set up one of the authentication mechanisms (e.g. WAMP-CRA) and then your component would do something like: self.join(u'admin_realm', [u'wampcra'], u'admin') in onConnect and compute the challenge in onChallenge using their secret, as per the docs: http://crossbar.io/docs/WAMP-CRA-Authentication/#python-frontend

On the router side, the simplest for WAMP-CRA is to use static credentials where you just users + secrets in the config.json file. You can define a dynamic WAMP-CRA auth

meejah
  • 316
  • 1
  • 5
  • I may have to try this. I could have swore that I saw an example that allowed this somewhere, but it could have been old. The configuration documentation, sometimes leaves me a bit confused. Thanks! – jaime Nov 05 '15 at 20:17
  • @jaime if you *do* become confused by the documentation, it would be very helpful to file a bug (against https://github.com/crossbario/crossbar) describing what was confusing.The more one gets into a project, the harder it becomes to see where new people get hung up ... :/ – meejah Nov 17 '15 at 16:40
0

Just gave this a try and can replicate the error. I've filed a bug for this - https://github.com/crossbario/crossbar/issues/507. Sorry for the inconvenience!

gzost
  • 2,375
  • 1
  • 18
  • 25