SyntaxCircus.Blazor.Auth
0.1.1
See the version list below for details.
dotnet add package SyntaxCircus.Blazor.Auth --version 0.1.1
NuGet\Install-Package SyntaxCircus.Blazor.Auth -Version 0.1.1
<PackageReference Include="SyntaxCircus.Blazor.Auth" Version="0.1.1" />
<PackageVersion Include="SyntaxCircus.Blazor.Auth" Version="0.1.1" />
<PackageReference Include="SyntaxCircus.Blazor.Auth" />
paket add SyntaxCircus.Blazor.Auth --version 0.1.1
#r "nuget: SyntaxCircus.Blazor.Auth, 0.1.1"
#:package SyntaxCircus.Blazor.Auth@0.1.1
#addin nuget:?package=SyntaxCircus.Blazor.Auth&version=0.1.1
#tool nuget:?package=SyntaxCircus.Blazor.Auth&version=0.1.1
SyntaxCircus.Blazor.Auth
Server-side OIDC token forwarding, refresh, and resilience for interactive Blazor Server applications. The tokens issued at cookie/OIDC sign-in are cached, refreshed, and attached to outgoing calls to your backend API — on the initial HTTP request and later inside the SignalR circuit, where there's no HttpContext to read the auth cookie from.
No support guaranteed. Published as-is and maintained on a best-effort basis. Issues and PRs are welcome, but there's no SLA — fork it or vendor what you need if that's not enough.
Usage
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddBlazorTokenForwarding(builder.Configuration);
builder.Services.AddHttpClient<IMyApiClient, MyApiClient>(client =>
client.BaseAddress = new Uri(builder.Configuration["Api:BaseUrl"]!))
.AddHttpMessageHandler<ApiAuthHandler>();
var app = builder.Build();
app.UseAuthentication();
app.UseAuthorization();
app.UseBlazorTokenCache(); // after UseAuthorization(), before antiforgery
app.UseAntiforgery();
Configure normal cookie + OIDC authentication yourself (with SaveTokens = true and the offline_access scope) — this package only handles what happens to the tokens after sign-in.
Configuration
| Section | Purpose |
|---|---|
Authentication:Oidc |
Authority, ClientId, ClientSecret, Scopes, TokenCache:RefreshSkewSeconds, TokenCache:FallbackAccessTokenLifetimeSeconds |
Authentication:Oidc:TokenCache:Redis |
Enabled, ConnectionString, InstanceName — set Enabled: true to back the token cache with Redis for multi-instance deployments; in-process otherwise |
Api |
BaseUrl, TimeoutSeconds |
Api:ClientCredentials |
Optional. TokenEndpoint, ClientId, ClientSecret, Audience, Scope — when set, anonymous circuit calls fall back to a client-credentials (M2M) token instead of going out unauthenticated |
Extras
SyntaxCircus.Blazor.Auth.Diagnostics.AuthDebugEndpoints.MapAuthDebugEndpoints()— opt-in/debug/claimsand/debug/tokenendpoints for inspecting the current principal and cached tokens. Never wired automatically; call it yourself, gated behindIsDevelopment().SyntaxCircus.Blazor.Auth.Components.Errors.GlobalErrorBoundary/GlobalErrorView/LoggingErrorBoundary— a Bootstrap-styled error boundary that logs unhandled exceptions and auto-recovers on navigation.SyntaxCircus.Blazor.Auth.Components.Layout.ReconnectModal— the standard Blazor Server reconnect-UI markup (rejoin animation, pause/resume states).
Contributing
Issues and pull requests are welcome:
- Keep changes focused, with a clear description of the behavior change.
- Match the existing code style (see
.editorconfig). - Call out any breaking changes to the public API in your PR description.
License
MIT — see LICENSE.txt.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.AspNetCore.Authentication.OpenIdConnect (>= 10.0.11)
- Microsoft.Extensions.Caching.StackExchangeRedis (>= 10.0.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.