Closed Boscop closed 7 years ago
It does now! This is part of some other work I've been doing, and I've been focused on those, but with the recent massive changes to serde, it makes sense to bring this up to date.
Thanks! Btw, which js lib would you recommend to use in the browser to communicate with wamp-rs? I want to do a web gui for a Rust app, so I need to send key strokes, events, and the server needs to push gui data updates.
And for a different app I want to send push notifications to users, so I need to read the user id from the cookie when a websocket connection comes in, is this possible with wamp-rs?
I've personally used AutobahnJS for my websocket library in Javascript, and had no problems at all.
As for reading from a cookie, I don't think the WAMP protocol supports that directly, since the router isn't supposed to do anything but relay messages, and the cookie would get lost by the time it got to the callee. I suspect you'd be best to store a user ID (or maybe the session id) in localStorage on the client side, and then pass that along. Another thing that might be useful is the publish blacklist/whitelist feature, which is part of the advanced profile, but hasn't been implemented here yet.
Something you could do, if your user id was 1234, is subscribe to a topic like com.my.topic.1234. Then you can publish to com.my.topic.1234 for that particular user. However, given that WAMP-RS doesn't currently support user authentication, you'd have to be careful about security there.
I hope those random thoughts help. Any feature you would like to see in WAMP-RS, feel free to request it, or better yet, implement!
Thanks. But how can I authenticate users without cookies so that nobody can impersonate another user? Also, with publishing, doesn't that send all messages to all clients, and they then decide which ones to look at? That would cause a lot of unnecessary traffic. If possible I want to send only to the client that should get the message..
For authentication, until I (or someone else) implements it in WAMP-RS, I don't know how you might do it. The ws library didn't support cookies when last I checked, although they might now. I guess that's a pretty critical feature for what you're trying to accomplish. But with publishing, no every client doesn't see every message. They only see the messages for topics they are subscribed to. So as long as each user had their own topic for messages, only they would see the notifications.
It should be possible to read the cookie in Handler::on_request() https://github.com/housleyjk/ws-rs/issues/110
Does this work with the latest ws-rs and serde?