AspiriFriday.Hosting.UserJwts is a small Aspire hosting integration that gives you a dotnet user-jwts-style developer experience for distributed apps. Initial version was built on AspiriFriday stream.
Warning
This package is under active development. The API may change without notice.
var signingKey = builder.AddJwtSigningToken("signing-key");
resource.WithJwtToken(
signingKey,
commandName: "jwt-user",
displayName: "Generate Token",
description: "Generate a signed user JWT bearer token using the configured static signing key.",
additionalClaims: new Dictionary<string, JwtClaimDefault>
{
["aud"] = new("dotnetappwithauth"),
["sub"] = new("", UserConfigurable: true, Label: "User ID", Description: "Value used for the sub claim."),
["age"] = new("18", UserConfigurable: true, Label: "Age claim", Description: "User's age used for authorization checks."),
});dotnet user-jwts is great for local API auth workflows, but in distributed Aspire apps you often want token generation to be:
- visible from the dashboard,
- attached to a specific resource,
- preconfigured with claim templates,
- easy for teammates to use without remembering exact claims, or CLI syntax.
This package provides that workflow.
- Creates signed JWT bearer tokens for local development.
- Supports predictable default claims and issuer values.
- Supports token lifetime and standard temporal claims (
nbf,iat,exp). - Lets you customize claim values for specific scenarios.
-
dotnet user-jwts: CLI-first (dotnet user-jwts create ...). -
AspiriFriday.Hosting.UserJwts: dashboard-first (resource command in AppHost). -
dotnet user-jwts: typically configured per API project. -
AspiriFriday.Hosting.UserJwts: configured once in AppHost and shared across resources. -
dotnet user-jwts: you pass arguments each time. -
AspiriFriday.Hosting.UserJwts: you define reusable command templates with optional interactive prompts.
Add the package to your AppHost project:
dotnet add package AspiriFriday.Hosting.UserJwtsIn your AppHost, register a signing key resource:
var builder = DistributedApplication.CreateBuilder(args);
var signingKey = builder.AddJwtSigningToken("signing-key");By default, the signing key is generated as a secret parameter and persisted for local reuse.
Add one or more JWT generation commands to a project (or executable) resource:
builder.AddProject<Projects.MyApi>("api")
.WithJwtToken(
signingKey,
commandName: "jwt-user",
displayName: "Generate User Token",
description: "Generate a signed user JWT for local API testing.",
additionalClaims: new Dictionary<string, JwtClaimDefault>
{
["aud"] = new("my-api"),
["sub"] = new("dev-user", UserConfigurable: true, Label: "User ID"),
["age"] = new("18", UserConfigurable: true, Label: "Age")
});Run AppHost, open the Aspire dashboard, then execute the resource command. The command returns a bearer token you can paste into Swagger, Scalar, Postman, curl, or your HTTP files.
dotnet build
dotnet testThe package is designed for local development and testing workflows in Aspire environments, mirroring the ergonomics of dotnet user-jwts while integrating directly into AppHost and dashboard resource commands.
