vue-signalr
vue-signalr copied to clipboard
Is there any way to use accessTokenFactory?
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
Any information about this?
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
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(