Convex.Client.Extensions.AspNetCore 3.0.0-alpha

This is a prerelease version of Convex.Client.Extensions.AspNetCore.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Convex.Client.Extensions.AspNetCore --version 3.0.0-alpha
                    
NuGet\Install-Package Convex.Client.Extensions.AspNetCore -Version 3.0.0-alpha
                    
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="Convex.Client.Extensions.AspNetCore" Version="3.0.0-alpha" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Convex.Client.Extensions.AspNetCore" Version="3.0.0-alpha" />
                    
Directory.Packages.props
<PackageReference Include="Convex.Client.Extensions.AspNetCore" />
                    
Project file
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 Convex.Client.Extensions.AspNetCore --version 3.0.0-alpha
                    
#r "nuget: Convex.Client.Extensions.AspNetCore, 3.0.0-alpha"
                    
#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 Convex.Client.Extensions.AspNetCore@3.0.0-alpha
                    
#: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=Convex.Client.Extensions.AspNetCore&version=3.0.0-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Convex.Client.Extensions.AspNetCore&version=3.0.0-alpha&prerelease
                    
Install as a Cake Tool

Convex.Client.Extensions.AspNetCore

ASP.NET Core integration for the Convex .NET Client.

Overview

This package provides ASP.NET Core-specific extensions for the Convex .NET Client, including:

  • Authentication Middleware: Automatically extract JWT tokens from HTTP requests
  • Health Checks: Monitor Convex client connectivity and performance
  • HttpContext Integration: Seamless integration with ASP.NET Core request pipeline

Installation

dotnet add package Convex.Client.Extensions.AspNetCore

Note: This package automatically includes Convex.Client.Extensions as a dependency.

Requirements

  • .NET 8.0 or .NET 9.0
  • ASP.NET Core server runtime (not compatible with Blazor WebAssembly)

Features

Authentication Middleware

Automatically extract and set Convex authentication tokens from HTTP requests:

// Program.cs
using Convex.Client.Extensions.DependencyInjection;
using Convex.Client.Extensions.AspNetCore.Middleware;

var builder = WebApplication.CreateBuilder(args);

// Register Convex client
builder.Services.AddConvex("https://your-deployment.convex.cloud");

var app = builder.Build();

// Add Convex authentication middleware
app.UseConvexAuth(options =>
{
    options.LogAuthenticationChanges = true;
    options.RejectInvalidTokens = false;
    options.ClearAuthIfNoToken = false;
});

app.Run();

Middleware Options:

  • LogAuthenticationChanges: Log when auth tokens are set/cleared (default: false)
  • RejectInvalidTokens: Return 401 for invalid tokens (default: false)
  • ClearAuthIfNoToken: Clear auth when no token present (default: false)
  • CustomTokenHeader: Extract token from custom header
  • CustomAuthScheme: Support custom authentication schemes
  • CustomTokenExtractor: Custom token extraction logic

Health Checks

Monitor Convex client connectivity:

using Convex.Client.Extensions.DependencyInjection;
using Convex.Client.Extensions.AspNetCore.HealthChecks;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddConvex("https://your-deployment.convex.cloud");

// Add Convex health check
builder.Services.AddHealthChecks()
    .AddConvexCheck(
        name: "convex",
        options: new ConvexHealthCheckOptions
        {
            HealthCheckFunctionName = "health:ping", // Optional: custom health check function
            HealthCheckArgs = null
        });

var app = builder.Build();

app.MapHealthChecks("/health");
app.Run();

Usage with Blazor WebAssembly

Important: This package is for ASP.NET Core server projects only. For Blazor WebAssembly projects, use only the Convex.Client.Extensions package:

# Blazor WASM - DO NOT use AspNetCore package
dotnet add package Convex.Client.Extensions

Migration from v1.x

If you were using Convex.Client.Extensions v1.x with ASP.NET Core features:

  1. Install the AspNetCore package:

    dotnet add package Convex.Client.Extensions.AspNetCore --version 2.0.0
    
  2. Update namespace imports:

    // OLD
    using Convex.Client.Extensions.Middleware;
    using Convex.Client.Extensions.HealthChecks;
    
    // NEW
    using Convex.Client.Extensions.AspNetCore.Middleware;
    using Convex.Client.Extensions.AspNetCore.HealthChecks;
    
  3. Keep using Convex.Client.Extensions.DependencyInjection for AddConvex() (unchanged)

Example: Full Integration

using Convex.Client.Extensions.DependencyInjection;
using Convex.Client.Extensions.AspNetCore.Middleware;
using Convex.Client.Extensions.AspNetCore.HealthChecks;

var builder = WebApplication.CreateBuilder(args);

// Register Convex client
builder.Services.AddConvex(builder.Configuration);

// Add health checks
builder.Services.AddHealthChecks()
    .AddConvexCheck();

var app = builder.Build();

// Add authentication middleware (before authorization)
app.UseConvexAuth(options =>
{
    options.LogAuthenticationChanges = app.Environment.IsDevelopment();
    options.RejectInvalidTokens = true;
});

app.UseAuthorization();

app.MapHealthChecks("/health");
app.MapControllers();

app.Run();

Configuration

Add Convex configuration to appsettings.json:

{
  "Convex": {
    "DeploymentUrl": "https://your-deployment.convex.cloud",
    "Timeout": "00:00:30"
  }
}

License

MIT License - see LICENSE for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  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 was computed.  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.

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

Initial release (0.0.1) providing ASP.NET Core middleware for authentication token handling and health check integration. See CHANGELOG.md for full details.