run authentication example as part of CI
Trying to log in to the server via wampcra on the wamp server, when attempting to authorize in the log error:### Left reason = wamp.error.authorization _ failed, message = invalid password, though via autobahn-python everything works fine, password correct. Here is my authorization code:
Session session = new Session ();
IAuthenticator authenticator = new ChallengeResponseAuth(authid, secret);
Client client = new Client(session, url, realm, authenticator);
CompletableFuture<ExitInfo> exitInfoCompletableFuture = client.connect();
we have a working example for WAMP-CRA auth here: https://github.com/crossbario/autobahn-java/blob/master/demo-gallery/src/main/java/io/crossbar/autobahn/demogallery/AuthenticationExampleClient.java
could you try that and see if it works for you?
Hi, I have the following code in the android app in which I try to connect to the server via wamp-cra, when trying to connect the server gives out an error that is not the correct password
CODE: try { Session session = new Session(); session.addOnConnectListener(this::onConnectCallback); session.addOnJoinListener(this::onJoinCallback); session.addOnLeaveListener(this::onLeaveCallback); session.addOnDisconnectListener(this::onDisconnectCallback); Client client = new Client(session, url, realm, new ChallengeResponseAuth(authid, secret)); CompletableFuture<ExitInfo> exitFuture = client.connect(); try { ExitInfo exitInfo = exitFuture.get(); Log.d(LOG_TAG, exitInfo.toString()); } catch (Exception e) { Log.d(LOG_TAG, e.getMessage()); } } catch (Exception e) { Log.d(LOG_TAG, "Wamp session start error: ", e); } LOG: D/io.crossbar.autobahn.websocket.WebSocketReader: Created D/io.crossbar.autobahn.websocket.WebSocketConnection: WS reader created and started D/io.crossbar.autobahn.websocket.WebSocketReader: Running D/io.crossbar.autobahn.websocket.WebSocketWriter: Created D/io.crossbar.autobahn.websocket.WebSocketConnection: WS writer created and started D/io.crossbar.autobahn.websocket.WebSocketReader: Status: 101 (Switching Protocols) 'Server'='nginx/1.10.3' 'Date'='Tue, 15 Oct 2019 09:40:25 GMT' D/io.crossbar.autobahn.websocket.WebSocketReader: 'Connection'='upgrade' 'Upgrade'='websocket' 'Sec-WebSocket-Accept'='pYQRqc6spmFBw6hIPhKz67BfZZA=' 'Sec-WebSocket-Protocol'='wamp.2.json' D/io.crossbar.autobahn.websocket.WebSocketConnection: opening handshake received D/io.crossbar.autobahn.wamp.transports.AndroidWebSocket: Negotiated serializer=wamp.2.json W/Java7Support: Unable to load JDK7 types (annotations, java.nio.file.Path): no Java7 support added D/io.crossbar.autobahn.wamp.Session: onConnect() D/WAMP_log: Start session=0 D/io.crossbar.autobahn.wamp.Session: Called join() with realm=UVO
TX : io.crossbar.autobahn.wamp.messages.Hello@a2b08f2 D/io.crossbar.autobahn.websocket.WebSocketConnection: onOpen() called, ready to rock. D/io.crossbar.autobahn.wamp.Session: <<< RX : io.crossbar.autobahn.wamp.messages.Challenge@455ca1c D/io.crossbar.autobahn.wamp.Session: >>> TX : io.crossbar.autobahn.wamp.messages.Authenticate@9c3c625 D/io.crossbar.autobahn.wamp.Session: <<< RX : io.crossbar.autobahn.wamp.messages.Abort@458d3fa D/WAMP_log: Left reason=wamp.error.authorization_failed, message=invalid password D/io.crossbar.autobahn.wamp.Session: Notified Session.onLeave listeners, now closing transport D/io.crossbar.autobahn.websocket.WebSocketConnection: WebSockets Close received (1000 - null) D/io.crossbar.autobahn.websocket.WebSocketReader: Quit D/io.crossbar.autobahn.websocket.WebSocketWriter: Ended D/io.crossbar.autobahn.websocket.WebSocketReader: Ended D/io.crossbar.autobahn.websocket.WebSocketReader: Quit D/io.crossbar.autobahn.wamp.transports.AndroidWebSocket: Disconnected, code=1, reasons=null D/io.crossbar.autobahn.wamp.Session: onDisconnect(), wasClean=true D/WAMP_log: Session with ID=0, disconnected. D/io.crossbar.autobahn.wamp.Session: Notified all Session.onDisconnect listeners. I/System.out: io.crossbar.autobahn.wamp.types.ExitInfo@7c49dab
Среда, 16 октября 2019, 12:15 +03:00 от Tobias Oberstein [email protected]:
we have a working example for WAMP-CRA auth here: https://github.com/crossbario/autobahn-java/blob/master/demo-gallery/src/main/java/io/crossbar/autobahn/demogallery/AuthenticationExampleClient.java could you try that and see if it works for you? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub , or unsubscribe .
С уважением, Олег Борисов
we have a working example for WAMP-CRA auth here: https://github.com/crossbario/autobahn-java/blob/master/demo-gallery/src/main/java/io/crossbar/autobahn/demogallery/AuthenticationExampleClient.java
could you try that and see if it works for you?
this example not work for me((
Tell me please, maybe there are some working examples under android to connect with wamp-cra?
this example not work for me((
what exactly does not work?
invalid password in the log gives a hint;)
also: what router? if crossbar, pls include output from crossbar version ..
the password is valid, I have a client on a python using a crossbar that also via wamp-cra connects to the same router without problems. Router - modified turnpike library implementation on golang
my working python code example:
import asyncio from autobahn.asyncio.wamp import ApplicationSession, ApplicationRunner from autobahn.wamp import auth from pprint import pprint USER = 'user' USER_SECRET = '123456' class Component(ApplicationSession): def onConnect(self): print("Client session connected. Starting WAMP-CRA authentication as user '{}'".format(USER)) self.join(u'XXX', [u'wampcra'], USER) def onChallenge(self, challenge): print('Authentication challenge received') key = auth.derive_key(USER_SECRET, challenge.extra['salt'], challenge.extra['iterations'], challenge.extra['keylen']) signature = auth.compute_wcs(key, challenge.extra['challenge']) return signature async def onJoin(self, details): pass def onDisconnect(self): pass
if name == 'main': url = u"wss://xxx.ru/ws/" realm = u"XXX" try: runner = ApplicationRunner(url, realm) runner.run(Component) except Exception as e: print(e)
Пятница, 18 октября 2019, 15:02 +03:00 от Tobias Oberstein [email protected]:
this example not work for me(( what exactly does not work? invalid password in the log gives a hint;) also: what router? if crossbar, pls include output from crossbar version .. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub , or unsubscribe .
С уважением, Олег Борисов
@om26er to cut down in time spent, we should add https://github.com/crossbario/autobahn-java/blob/master/demo-gallery/src/main/java/io/crossbar/autobahn/demogallery/AuthenticationExampleClient.java to the CI tests automatically run
that is, test (from ABJ under netty) that all 3 auth methods do work: WAMP-CRA, WAMP-Cryptosign, WAMP-Ticket against the CB started as part of the CI.
essentially extend CI so these auth tests can be looked at as part of the travis log https://travis-ci.org/crossbario/autobahn-java
Works for me, here is the code that I used in android to test
private void testAuth() {
exampleCRA("ws://192.168.1.236:8080/ws", "realm1", "joe", "secret2");
}
private static CompletableFuture<ExitInfo> connect(
String websocketURL, String realm, IAuthenticator authenticator) {
Session wampSession = new Session();
wampSession.addOnJoinListener((session, details) -> System.out.println("Joined session."));
Client client = new Client(wampSession, websocketURL, realm, authenticator);
return client.connect();
}
public static CompletableFuture<ExitInfo> exampleCRA(
String websocketURL, String realm, String authid, String secret) {
return connect(websocketURL, realm, new ChallengeResponseAuth(authid, secret));
}
And here is the config
{
"$schema": "https://raw.githubusercontent.com/crossbario/crossbar/master/crossbar.json",
"version": 2,
"controller": {
},
"workers": [
{
"type": "router",
"realms": [
{
"name": "realm1",
"roles": [
{
"name": "frontend",
"permissions": [
{
"uri": "",
"match": "prefix",
"allow": {
"call": true,
"register": true,
"publish": true,
"subscribe": true
},
"disclose": {
"caller": false,
"publisher": false
},
"cache": true
}
]
}
]
}
],
"transports": [
{
"type": "web",
"endpoint": {
"type": "tcp",
"port": 8080
},
"paths": {
"ws": {
"type": "websocket",
"auth": {
"wampcra": {
"type": "static",
"users": {
"joe": {
"secret": "secret2",
"role": "frontend"
}
}
}
}
}
}
}
]
}
]
}