DX.Blazor.Identity.Server
26.1.3.28
dotnet add package DX.Blazor.Identity.Server --version 26.1.3.28
NuGet\Install-Package DX.Blazor.Identity.Server -Version 26.1.3.28
<PackageReference Include="DX.Blazor.Identity.Server" Version="26.1.3.28" />
<PackageVersion Include="DX.Blazor.Identity.Server" Version="26.1.3.28" />
<PackageReference Include="DX.Blazor.Identity.Server" />
paket add DX.Blazor.Identity.Server --version 26.1.3.28
#r "nuget: DX.Blazor.Identity.Server, 26.1.3.28"
#:package DX.Blazor.Identity.Server@26.1.3.28
#addin nuget:?package=DX.Blazor.Identity.Server&version=26.1.3.28
#tool nuget:?package=DX.Blazor.Identity.Server&version=26.1.3.28
DX.Blazor.Identity.Server
Server-side ASP.NET Core Identity integration for Blazor Server apps and the Web API backing a hosted Blazor WASM app — JWT issuing, cookie-based Server sign-in, and the base controllers your project's AuthenticationController/TokenController derive from.
Target frameworks: net9.0, net10.0
DevExpress dependency: transitive, via DX.Blazor.Identity → DX.Data.Xpo.Identity (26.1.*)
Install
dotnet add package DX.Blazor.Identity.Server
AuthenticationService<TKey, TUser, TRegistrationModel, TAuthenticationModel> (Services/AuthenticationService.cs)
public abstract class AuthenticationService<TKey, TUser, TRegistrationModel, TAuthenticationModel> : IAuthService<TRegistrationModel, TAuthenticationModel>
{
// Uses UserManager<TUser>, IDataProtectionProvider, NavigationManager
public Task<RegistrationResponseModel> RegisterUser(TRegistrationModel model); // POSTs JSON to /api/Accounts/Registration
public Task<AuthResponseModel> Login(TAuthenticationModel model);
public Task Logout();
public Task<string> RefreshToken();
}
public abstract class AuthenticationService<TKey, TUser, TRegistrationModel> : AuthenticationService<TKey, TUser, TRegistrationModel, AuthenticationModel> { }
public class AuthenticationService<TUser, TRegistrationModel> : AuthenticationService<string, TUser, TRegistrationModel> { }
public class AuthenticationService<TUser> : AuthenticationService<TUser, RegistrationModel>, IAuthService { }
This is the Blazor Server-specific IAuthService implementation. Rather than storing a JWT in browser storage (as the WASM variant does), it protects a token payload with IDataProtectionProvider and performs a hard, NavigationManager.NavigateTo(..., forceLoad: true) redirect to a GET /api/Accounts/Login?token=... endpoint, letting the server sign the user in via cookie authentication (SignInManager.SignInAsync) — the right pattern for Blazor Server, where there's no client-side JS to hold a bearer token.
AuthenticationControllerBase<TKey, TUser, TRegistrationModel> (Controllers/AuthenticationControllerBase.cs)
public abstract class AuthenticationControllerBase<TKey, TUser, TRegistrationModel> : Controller
{
[HttpPost("Registration")] public Task<IActionResult> RegisterUser(TRegistrationModel model);
[HttpPost("Login")] public Task<IActionResult> Login(AuthenticationModel model); // returns JWT directly (WASM flow)
[HttpGet("Login")] public Task<IActionResult> Login(string token); // unprotects token, verifies, SignInAsync (Server flow)
[HttpGet("ExternalLogins")] public IActionResult ExternalLogins();
[HttpGet("LogOut")] public Task<IActionResult> Logout();
}
Your project's own AuthenticationController (or AccountController) derives from this and supplies UserManager<TUser>, SignInManager<TUser>, IDataProtectionProvider, ILogger, and IConfiguration via constructor injection — see the root README for the exact controller shape for both the Blazor Server and Hosted WASM scenarios. The signing key is read from JwtSettings:securityKey in IConfiguration.
TokenControllerBase<TKey, TUser> (Controllers/TokenControllerBase.cs)
public class TokenControllerBase<TKey, TUser> : ControllerBase
{
[HttpPost("refresh")] public Task<IActionResult> Refresh(RefreshTokenModel model);
}
Implements the refresh-token flow via the injected ITokenService<TKey, TUser> — used by the hosted WASM scenario's TokenController. Note: this file physically lives in DX.Blazor.Identity.Server/Controllers/ but its namespace is DX.Blazor.Identity.Wasm.Controllers (a pre-existing inconsistency in the codebase — your using statement needs to reference the Wasm.Controllers namespace even though the package you installed is .Server).
AuthStateProvider<TUser> (AuthStateStateProvider.cs)
public class AuthStateProvider<TUser> : RevalidatingServerAuthenticationStateProvider where TUser : class
{
protected override TimeSpan RevalidationInterval => TimeSpan.FromMinutes(30);
protected override Task<bool> ValidateAuthenticationStateAsync(AuthenticationState state, CancellationToken ct);
}
Registered as AuthenticationStateProvider in Blazor Server apps — periodically (every 30 minutes) re-validates the signed-in user's security stamp against a freshly-resolved UserManager<TUser> from a new DI scope, so a password change or lockout invalidates the session without waiting for the circuit to reconnect.
Supporting services (Services/)
public interface IUserService { string GetCurrentUserId(); string GetCurrentUserName(); }
public class UserService : IUserService { /* reads ClaimTypes.Sid / ClaimTypes.Name off HttpContext.User */ }
public class TokenAccessService { public string GetToken(); /* reads the "access_token" auth-scheme token off HttpContext */ }
Small convenience services for pulling the current user's id/name or the raw access token out of HttpContext from anywhere in the DI graph (e.g. a scoped service that doesn't have direct controller access).
TokenProvider (TokenProvider.cs)
public class TokenProvider { public string AccessToken { get; set; } public string RefreshToken { get; set; } }
A trivial scoped DTO used to pass the current token pair around within a single Blazor Server circuit.
Notes
- See the root README for the complete DI registration and controller code for both Blazor Server and Blazor Hosted WASM setups.
- Pairs with
DX.Blazor.Identity.Wasmfor the hosted-WASM scenario (this package hosts the Web API; the WASM package is the client).
See the root README for the full package list and DevExpress version alignment notes.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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
- DX.Blazor.Identity (>= 26.1.3.30)
- Microsoft.AspNetCore.Components.Web (>= 10.0.10)
- Microsoft.AspNetCore.Components.WebAssembly.Server (>= 10.0.10)
-
net9.0
- DX.Blazor.Identity (>= 26.1.3.30)
- Microsoft.AspNetCore.Components.Web (>= 9.0.18)
- Microsoft.AspNetCore.Components.WebAssembly.Server (>= 9.0.18)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
26.1.3.28: Rebuilt against DX.Blazor.Identity 26.1.3.30 to pick up the System.Security.Cryptography.Xml 8.0.4 fix (NU1903) transitively.
26.1.3.27: Added a README.md with technical documentation, now embedded in the package via PackageReadmeFile. Rebuilt against DX.Blazor.Identity 26.1.3.29.
26.1.3.26: Rebuilt against DX.Blazor.Identity 26.1.3.28 to pick up DevExpress v26.1.3 transitively.
23.2.3.23: Upgraded to .NET 8 and DX v23.2
22.1.4.20: Upgraded several packages
22.1.4.19: Upgraded several packages incl DevExpress v21.1.4
21.2.8.18: New helper package for DX.Blazor.Identity with everything for Blazor Server and WebAPI for Blazor WASM package to easily implement Identity with XPO on Blazor