Skip to content

Support Authentication Refresh for Azure SignalR (Default mode)#2277

Merged
MoChilia merged 10 commits into
devfrom
shiyingchen/refresh_auth_sdk
Jul 8, 2026
Merged

Support Authentication Refresh for Azure SignalR (Default mode)#2277
MoChilia merged 10 commits into
devfrom
shiyingchen/refresh_auth_sdk

Conversation

@MoChilia

@MoChilia MoChilia commented Jul 2, 2026

Copy link
Copy Markdown
Member

Summary

Implements the Default-mode SDK side of #2278. See the issue for the full background, API design, and behavior/semantics. This PR is the server-SDK implementation.

What this PR does

Lets an app refresh an Azure SignalR client connection's auth expiration and application claims without reconnecting. The SDK intercepts {hubUrl}/refresh for ASRS-connected hubs and applies the refresh over the service connection. Apps opt in through the same HttpConnectionDispatcherOptions self-hosted SignalR uses without new public API introduced in Microsoft.Azure.SignalR.

Changes

All new code is internal and net11-guarded (#if NET11_0_OR_GREATER); netstandard2.0 /net8.0 builds are unaffected. The service protocol messages RefreshAuthMessage (41), GetConnectionClaimsMessage (42), UpdateConnectionClaimsMessage (43) have already been released in v1.33.1.

  • AuthRefreshMatcherPolicy — intercepts /refresh for ASRS-connected hubs.
  • RefreshHandler — request validation + optional OnAuthenticationRefresh gate; sends RefreshAuthMessage; mints the refreshed service access token; returns { accessToken, tokenLifetimeSeconds } or { error }.
  • NegotiateHandler — advertises tokenLifetimeSeconds for eligible connections.
  • Claims propagation — the owning app server applies UpdateConnectionClaimsMessage to Context.User (IConnectionUserFeature + net11 IConnectionUserRefreshFeature), then Hub.OnAuthenticationRefreshedAsync() runs.
  • Container/managerRefreshConnectionAuthAsync / GetConnectionClaimsAsync with new result records; AckHandler carries claim payloads; AckStatus.Forbidden added.
  • Multi-endpoint sharding — refresh pins to the connection's owning ServiceEndpoint (no rebalance / re-negotiate).
  • Build/CI — adds the net11.0 target; workflows install the .NET 11 daily SDK (Remove it when .NET 11 is GA)

Not in scope

  • Serverless / Management mode — interface members are stubbed and throw NotSupportedException (// TODO: Serverless refresh support); a later PR implements it.

Tests

  • RefreshAuthFacts — handler success, gating (opt-in / auth / Windows / anonymous), OnAuthenticationRefresh accept/reject, typed failures, token minting.
  • MultiEndpointServiceConnectionContainerTests — owner pinning, fan-out discovery, ambiguous-owner failure.
  • ServiceHubDispatcherTests + test-infra updates for the new container/manager members.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@MoChilia MoChilia changed the title Support Authentication Refresh for Azure SignalR Support Authentication Refresh for Azure SignalR (Default mode) Jul 6, 2026
@MoChilia MoChilia linked an issue Jul 6, 2026 that may be closed by this pull request
@MoChilia MoChilia marked this pull request as ready for review July 6, 2026 03:16
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@MoChilia MoChilia requested a review from vwxyzh July 6, 2026 03:17
@MoChilia MoChilia removed the enhancement New feature or request label Jul 8, 2026
@MoChilia MoChilia added the enhancement New feature or request label Jul 8, 2026
@MoChilia MoChilia merged commit ddfb043 into dev Jul 8, 2026
10 checks passed
@MoChilia MoChilia deleted the shiyingchen/refresh_auth_sdk branch July 8, 2026 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Azure SignalR Authentication Refresh for Default Mode

2 participants