FractalDataWorks.Services.Authentication.Jwt
0.20.0-alpha.1074
This is a prerelease version of FractalDataWorks.Services.Authentication.Jwt.
dotnet add package FractalDataWorks.Services.Authentication.Jwt --version 0.20.0-alpha.1074
NuGet\Install-Package FractalDataWorks.Services.Authentication.Jwt -Version 0.20.0-alpha.1074
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="FractalDataWorks.Services.Authentication.Jwt" Version="0.20.0-alpha.1074" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FractalDataWorks.Services.Authentication.Jwt" Version="0.20.0-alpha.1074" />
<PackageReference Include="FractalDataWorks.Services.Authentication.Jwt" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add FractalDataWorks.Services.Authentication.Jwt --version 0.20.0-alpha.1074
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: FractalDataWorks.Services.Authentication.Jwt, 0.20.0-alpha.1074"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package FractalDataWorks.Services.Authentication.Jwt@0.20.0-alpha.1074
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=FractalDataWorks.Services.Authentication.Jwt&version=0.20.0-alpha.1074&prerelease
#tool nuget:?package=FractalDataWorks.Services.Authentication.Jwt&version=0.20.0-alpha.1074&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
FractalDataWorks.Services.Authentication.Jwt
JWT-based authentication service with role-based authorization for FractalDataWorks applications.
Features
- JWT access token generation and validation
- Refresh token support with secure storage
- Role-based authorization
- Integration with IDataGateway for user storage
- ASP.NET Core JWT Bearer middleware integration
- Token revocation support
Usage
// In Program.cs or Startup.cs
builder.Services.AddFullJwtAuthentication(builder.Configuration);
builder.Services.AddDataServices(builder.Configuration); // Required for user storage
var app = builder.Build();
app.UseAuthentication();
app.UseAuthorization();
Configuration
{
"Services": {
"Authentication": {
"Jwt": {
"Issuer": "https://your-app.com",
"Audience": "https://your-app.com",
"SecretKey": "your-256-bit-secret-key-here-minimum-32-chars",
"AccessTokenExpirationMinutes": 60,
"RefreshTokenExpirationMinutes": 10080,
"ValidateIssuer": true,
"ValidateAudience": true,
"ValidateLifetime": true,
"ValidateIssuerSigningKey": true,
"RoleClaimType": "role",
"NameClaimType": "name",
"AvailableRoles": ["Admin", "User", "ReadOnly"],
"UserStoreConnectionName": "ConfigurationDatabase",
"UsersTableName": "Users",
"UserRolesTableName": "UserRoles"
}
}
}
}
Database Schema
The service expects the following tables in the configured connection:
Users Table
CREATE TABLE Users (
Id NVARCHAR(50) PRIMARY KEY,
Username NVARCHAR(100) NOT NULL UNIQUE,
Email NVARCHAR(255) NOT NULL,
PasswordHash NVARCHAR(500) NOT NULL,
IsActive BIT NOT NULL DEFAULT 1,
CreatedAt DATETIME2 NOT NULL DEFAULT GETUTCDATE(),
UpdatedAt DATETIME2 NULL
);
UserRoles Table
CREATE TABLE UserRoles (
UserId NVARCHAR(50) NOT NULL,
RoleName NVARCHAR(50) NOT NULL,
PRIMARY KEY (UserId, RoleName),
FOREIGN KEY (UserId) REFERENCES Users(Id)
);
Login Endpoint Example
public sealed class LoginEndpoint : Endpoint<LoginRequest, LoginResponse>
{
private readonly IJwtAuthenticationService _authService;
public LoginEndpoint(IJwtAuthenticationService authService)
{
_authService = authService;
}
public override void Configure()
{
Post("/api/auth/login");
AllowAnonymous();
}
public override async Task HandleAsync(LoginRequest req, CancellationToken ct)
{
var result = await _authService.Login(req.Username, req.Password, ct);
if (result.IsFailure)
{
await SendUnauthorizedAsync(ct);
return;
}
await SendAsync(new LoginResponse
{
AccessToken = result.Value!.AccessToken,
RefreshToken = result.Value.RefreshToken,
ExpiresAt = result.Value.AccessTokenExpiresAt
}, cancellation: ct);
}
}
See Also
| 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- FractalDataWorks.Commands.Data (>= 0.20.0-alpha.1074)
- FractalDataWorks.Commands.Data.Extensions (>= 0.20.0-alpha.1074)
- FractalDataWorks.Configuration (>= 0.20.0-alpha.1074)
- FractalDataWorks.MessageLogging.Abstractions (>= 0.20.0-alpha.1074)
- FractalDataWorks.Services (>= 0.20.0-alpha.1074)
- FractalDataWorks.Services.Authentication (>= 0.20.0-alpha.1074)
- FractalDataWorks.Services.Authentication.Abstractions (>= 0.20.0-alpha.1074)
- FractalDataWorks.Services.Data.Abstractions (>= 0.20.0-alpha.1074)
- FractalDataWorks.Web.Http.Abstractions (>= 0.20.0-alpha.1074)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 10.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Identity.Core (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- System.IdentityModel.Tokens.Jwt (>= 8.14.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.20.0-alpha.1074 | 179 | 12/10/2025 |
| 0.20.0-alpha.1070 | 179 | 12/10/2025 |
| 0.20.0-alpha.1065 | 181 | 12/9/2025 |