One minute
JWT Authentication with SignalR and IdentityServer4
If you ever worked with SignalR and IdentityServer4, you probably did some “googling” around to figure how the heck JWT authentication works.
Especially since, the token might not be anymore in the request’s ‘Authentication’ attribute, and with SignalR’s preference to WebSocket and fallback transport options.
Maybe you found a lot of answers, maybe not.
In any case, the simplest one I have come across with is the following:
|
|
The snippet is originally from here and has been slighlty modified to my use-case.
Pay attention to lines 17-22 where TokenRetriever
is specified to get the token either from the Header or the Query
(also based on client-side implementation of SignalR).
PS: This works as intended with ASP.NET Core 3.0