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

Is there any way to use accessTokenFactory?

Open xandmore opened this issue 6 years ago • 3 comments

Hi! Would you, please, say is it possible to use accessTokenFactory? Is there any way to pass it? https://docs.microsoft.com/ru-ru/aspnet/core/signalr/configuration?view=aspnetcore-2.2&tabs=dotnet#configure-bearer-authentication

xandmore avatar Jun 10 '19 13:06 xandmore

Any information about this?

clustersnake avatar Sep 22 '20 15:09 clustersnake

for anyone who needs this, there is an authenticate method that you can use instead of the normal $socket.start which adds a query param (named authorization) to the connection url, then you need to create this middleware and use it by adding app.UseMiddleware<WebSocketsMiddleware>(); before app.UseAuthentication(); in your service configuration on your .net project (Startup.cs) you need then to edit the previous middleware by replacing access_token with authorization which is the query param used here

etshei avatar Sep 28 '20 23:09 etshei

If you already JWT tokens setup in your backend authentication, you can hook into the OnMessageReceived event in the AddJwtBearer options. https://docs.microsoft.com/en-us/aspnet/core/signalr/authn-and-authz?view=aspnetcore-3.1 Replace Request.Query["access_token"] with Request.Query["authorization"] to use the query param from the this.$socket.authenticate() call in your Vue client

kerrpeter avatar Jul 26 '21 10:07 kerrpeter