I need to use Windows Authentication for a hub, but since Im working in a bigger system, I can only access the SignalR Pipeline over the GlobalHost.
Ive tried using AuthorizedAttribute
, but that does not set the Identity, since there is no Autorization Module registered.
Ive tried setting GlobalHost.HubPipeline.RequireAuthentication();
That set the Identity, but since it sets Authorization globally, other Hubs can not connect.
Finally, I tried adding a custom Authorization module, that should only apply to the one hub I want. But as soon as I make an exception for one Hub, the Identity isnt set again, and I get an UnAuthrorized response from the Authorized Hub.
I usually put the authentication attribute on top of my hub class.
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
public class myChat : Hub
{
}
this is token-based authentication and you need to configure your send your authentication token from the client. https://learn.microsoft.com/en-us/as.net/core/signalr/authn-and-authz?view=as.netcore-3.1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.