-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I "setup" a session. #8
Comments
We use https://github.com/derbyparty/racer-highway as transport. It does everything for us. |
Ok, so based on this #6 (comment) and looking at the source code, I had to create a middleware that, on connect, sets a sharedb.use('connect', (request, next) => {
request.agent.connectSession = { userId: 123 };
next();
}); This is key information and I think it should be added to the documentation. Happy to create a PR for it if that helps? One more thing; getting the necessary information in the request object involves passing a second argument to Hope this comment ill be helpful for others Thanks Julien |
Thx @julienmachon that really helped me! Just to complete this with the websocket stuff for the case someone searches for a 'full' solution. It is possible to use a cookie, which is directly send to the connection request of the socket. In my case the authentication (and the user id) is stored in local storage, so I it was necessary to find a way to hand the user ID all the way from the client to the server socket, then to sharedb and finally to sharedb-access. So, on client you can set the user id using a query parameter as follows:
On the server you can take it from the url and hand it over to the ShareDB backend:
Afterwards the middleware can be used to store it in session:
Now it can be used in
|
How do you verify that user is real user with given id? |
Hi,
First of all, thanks for your work, you are making access control look easy. I have a major issue though.
The 3rd argument of each function is
session
. The documentation only sayssession - your connect session
but this is empty for me on read, and for a write operation for example, it is the content ofop
, sent by the client usingdoc.submitOp(op)
.I need to protect resources behind roles using JWT so I guess my question is "how do I setup a session". I've looked on the ShareDB documentation, but nothing is mentioned.
If you could point me out to the right direction, I'd be grateful.
Thanks
The text was updated successfully, but these errors were encountered: