Skip to content

Update Signalr hub authentication docs - #118

Merged
MikeAlhayek merged 2 commits into
mainfrom
docs/signalr-hub-authentication
Jul 28, 2026
Merged

Update Signalr hub authentication docs#118
MikeAlhayek merged 2 commits into
mainfrom
docs/signalr-hub-authentication

Conversation

@MikeAlhayek

Copy link
Copy Markdown
Member

This pull request adds comprehensive documentation on authentication and authorization for SignalR hubs in CrestApps, clarifying how to secure hubs and handle user identity in various scenarios. The new section explains both connection-level and per-invocation authorization models, demonstrates how to support headless clients with access tokens, and provides guidance on handling multiple authentication schemes and user identity within hubs.

Authentication and Authorization for SignalR Hubs:

  • Added a new section explaining that AddCoreSignalR() does not configure authentication, and that app.UseAuthentication() must run before endpoint routing for hubs.

  • Outlined two authorization models for hubs:

    • Connection-level: Use [Authorize] on the hub class to reject unauthorized connections during negotiation.
    • Per-invocation: Override authorization hooks (e.g., AuthorizeProfileAsync) to check access for each method call; default implementations allow all access, so they must be overridden for security.
  • Provided instructions and code samples for authenticating headless clients (e.g., SPAs, mobile apps) using bearer tokens via the access_token query parameter, including configuration for the JWT bearer handler and client-side token provision.

  • Explained how to support multiple authentication schemes (e.g., cookies and tokens) on a single hub by creating an explicit authorization policy

MikeAlhayek and others added 2 commits July 28, 2026 21:44
The SignalR page covered route management but said nothing about how a hub
authenticates or authorizes its callers, even though the chat hubs ship
with authorization hooks that permit everything until they are overridden.

- Describe the connection level and per-invocation authorization models,
  and list the hook each chat hub exposes along with its permissive
  default.
- Show how headless clients authenticate with a bearer token, including
  the `access_token` query string that SignalR falls back to during a
  WebSocket handshake.
- Explain when to require a scheme listing policy on a hub, and why that
  policy must not be applied to a hub that also accepts anonymous callers.
- Warn against resolving the caller through `IHttpContextAccessor` inside
  a hub invocation, and point to `Context.User` instead.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@MikeAlhayek
MikeAlhayek merged commit ece0f23 into main Jul 28, 2026
10 checks passed
@MikeAlhayek
MikeAlhayek deleted the docs/signalr-hub-authentication branch July 28, 2026 22:07
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.

1 participant