pythonauthenticationautobahncrossbarwamp-protocol

How to authenticate a WAMP connection via a ticket in python


I'm trying to connect to a WAMP bus from a different application that has certain roles configured. The roles are authenticated with a static ticket, so I believe that I need to declare what role I want to connect as and what the associated ticket is. I'm writing this in Python and have most of the component set up, but I can't find any documentation about how to do this sort of authentication.

from autobahn.twisted.component import Component, run

COMP = Component(
    realm=u"the-realm-to-connect",
    transports=u"wss://this.is.my.url/topic",
    authentication={
        # This is where I need help
        # u"ticket"?
        # u"authid"?
    }
)

Without the authentication, I'm able to connect to and publish to the WAMP bus when it is running locally on my computer, but that one is configured to allow anonymous users to publish. My production WAMP bus does not allow anonymous users to publish, so I need to authenticate what role this is connecting as. The Autobahn|Python documentation implies that it can be done in Python, but I've only been able to find examples of how to do it in JavaScript/JSON in Crossbar.io's documentation.


Solution

  • the documentation is not very up to date. With the Component it is necessary to do like that for tickets:

    from autobahn.twisted.component import Component, run
    
    component = Component(
        realm=u"the-realm-to-connect",
        transports=u"wss://this.is.my.url/topic",
        authentication={
            "ticket": {
                "authid": "username", 
                "ticket": "secrettoken"
            }
        },
    )