Skip to content

Document SignalR JavaScript client authentication refresh handler contexts and surface the feature in the JavaScript client article - #37696

Draft
wadepickett with Copilot wants to merge 3 commits into
mainfrom
copilot/v11-update-signalr-client-auth-refresh
Draft

wadepickett with Copilot wants to merge 3 commits into
mainfrom
copilot/v11-update-signalr-client-auth-refresh

Conversation

Copilot AI commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

The .NET 11 authentication refresh APIs for the @microsoft/signalr client are already documented accurately in the Refresh authentication from the JavaScript client subsection of xref:signalr/authn-and-authz, so that content is left unchanged. Two gaps remain: the canonical JavaScript client article never mentions the feature, and the existing subsection uses context.newTokenLifetimeInSeconds and context.error in examples without stating what the handler contexts expose or what makes a refresh fail.

aspnetcore/signalr/javascript-client.md — discoverability

  • Adds a short ## Refresh authentication without reconnecting section at the end of the body, before Related content.
  • The insertion point is inside a >= aspnetcore-6.0 zone, so that zone is closed, a >= aspnetcore-11.0 zone is opened for the new section, and the original zone is reopened with an identical range expression (openers/closers go from 2/2 to 4/4).
  • The section ends in a cross-reference to <xref:signalr/authn-and-authz#authentication-refresh> rather than duplicating the ~35 lines that already exist there — the authentication article remains the home for the server half that must be configured first.
const connection = new signalR.HubConnectionBuilder()
    .withUrl("/chathub", { accessTokenFactory: () => getAccessToken() })
    .withAuthenticationRefresh()
    .build();

aspnetcore/signalr/authn-and-authz.md — handler contract

  • Direct insertion into the existing >= aspnetcore-11.0 zone, after the IAuthenticationRefreshOptions list.
  • Lists the onAuthenticationRefreshed context members (connection, newTokenLifetimeInSeconds, refreshedAt) and the onAuthenticationRefreshFailed members (connection, error).
  • States the failure semantics: any non-200 response fails, including the HTTP 403 returned when the refreshed principal maps to a different SignalR user or when OnAuthenticationRefresh rejects — a policy outcome that warrants different UI handling than a transport error. A failed refresh doesn't close the connection on its own and isn't retried automatically; the connection runs on existing credentials until expiration, then closes if CloseOnAuthenticationExpiration is enabled.

Metadata

  • ms.date updated on both articles; ai-usage: ai-assisted added to javascript-client.md.

Verification

Each new statement was checked against product source at dotnet/aspnetcore@1fcd7ef: IAuthenticationRefreshOptions.ts (context shapes), HubConnection.ts (context construction, handlers fire on manual refresh, no reschedule and no close on failure), HttpConnection.ts (statusCode !== 200), AccessTokenHttpClient.ts (refresh re-invokes accessTokenFactory), HubConnectionBuilder.ts (options = {}, so the no-argument call above is valid), HttpConnectionDispatcher.cs (403 on rejection).

Open for reviewer judgment

Copilot AI and others added 2 commits September 20, 2026 15:41
…texts and add discoverability section

Co-authored-by: wadepickett <10985336+wadepickett@users.noreply.github.com>
Co-authored-by: wadepickett <10985336+wadepickett@users.noreply.github.com>
Copilot AI changed the title [WIP] Update SignalR TypeScript client to support authentication refresh Document SignalR JavaScript client authentication refresh handler contexts and surface the feature in the JavaScript client article Sep 20, 2026
Copilot AI requested a review from wadepickett September 20, 2026 15:50

## Authenticate users connecting to a SignalR hub

SignalR can be used with [ASP.NET Core authentication](xref:security/authentication/identity) to associate a user with each connection. In a hub, authentication data can be accessed from the <xref:Microsoft.AspNetCore.SignalR.HubConnectionContext.User?displayProperty=nameWithType> property. Authentication allows the hub to call methods on all connections associated with a user. For more information, see [Manage users and groups in SignalR](xref:signalr/groups). Multiple connections can be associated with a single user.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AntoniaEllison

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v11 update: SignalR TypeScript client supports authentication refresh

3 participants