azure-signalr icon indicating copy to clipboard operation
azure-signalr copied to clipboard

Can JWT access token be reused?

Open Jun2014 opened this issue 5 years ago • 8 comments

The client gets signalr service endpoint and JWT access token back, can client reuse this JWT access token to establish more than 1 connection? From the code, seems yes, want to confirm this.

Jun2014 avatar Aug 06 '19 18:08 Jun2014

Yes, it can. Sharing token means sharing the user info, which means all the connections for this client is one user. Could you share with us your scenario to share the token?

vicancy avatar Aug 14 '19 03:08 vicancy

In our case, we supports anonymous clients. We plan to issue signalr service endpoint and JWT access token back to the client, without specifying user id or auto-generate an unique user id. So the client may use this JWT access token to connect to our signalr service, and they can build as many connections. If that's the case, no other clients may be able to connect to the signalr service, since signalr service allows X number of connections. Is my understanding right? Thanks.

Jun2014 avatar Aug 14 '19 21:08 Jun2014

If that's the case, no other clients may be able to connect to the signalr service, since signalr service allows X number of connections

Yeah, that's the challenge when you allow anonymous clients that you might reach your instance connection limits quickly.

vicancy avatar Aug 15 '19 03:08 vicancy

Any idea to mitigate this? This sounds like a simple DOS.

Jun2014 avatar Aug 15 '19 05:08 Jun2014

You can abort the connection in Hub when OnConnectedAsync if the connections from one client exceeds your expectation using Context.Abort()

vicancy avatar Aug 15 '19 07:08 vicancy

You can abort the connection in Hub when OnConnectedAsync if the connections from one client exceeds your expectation using Context.Abort()

Hello @vicancy, How would you call Context.Abort() in Serverless mode? I'm using Azure Functions in Serverless mode which doesn't interface with hub classes.

kwasak avatar Jan 06 '20 18:01 kwasak

@kwasak For Serverless there is no such feature exposed yet, we are adding the feature and they will be available soon. (REST API for closing a connection will be available this month)

vicancy avatar Jan 08 '20 01:01 vicancy

@vicancy thanks for letting me know, I look forward to the API!

kwasak avatar Jan 08 '20 02:01 kwasak

Close a client connection is now supported https://github.com/Azure/azure-signalr/blob/dev/docs/management-sdk-guide.md

vicancy avatar Oct 26 '23 09:10 vicancy