Property Authenticate

Assembly: redb.Route.SignalR.dll

Authenticates a hub connection. Returns the principal to attach to the request (its
NameIdentifier claim becomes SignalR's UserIdentifier, which is what makes
Clients.User(...) and the redbSignalR.UserId header work), or null to reject
the handshake with 401 before the connection is upgraded.

Browsers cannot set headers on a WebSocket handshake, so a token normally arrives in the
access_token query parameter: read it from there and from the Authorization header.


The principal is also put on every exchange the hub produces (ExchangePrincipal). Build its
identity with an authentication type (new ClaimsIdentity(claims, "Bearer")): code that reads
the principal treats an identity that is not authenticated as anonymous.

public Func<HttpContext, Task<ClaimsPrincipal?>>? Authenticate { get; set; }