MesAuth.Authorizer 10.5.0

dotnet add package MesAuth.Authorizer --version 10.5.0
                    
NuGet\Install-Package MesAuth.Authorizer -Version 10.5.0
                    
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="MesAuth.Authorizer" Version="10.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MesAuth.Authorizer" Version="10.5.0" />
                    
Directory.Packages.props
<PackageReference Include="MesAuth.Authorizer" />
                    
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 MesAuth.Authorizer --version 10.5.0
                    
#r "nuget: MesAuth.Authorizer, 10.5.0"
                    
#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 MesAuth.Authorizer@10.5.0
                    
#: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=MesAuth.Authorizer&version=10.5.0
                    
Install as a Cake Addin
#tool nuget:?package=MesAuth.Authorizer&version=10.5.0
                    
Install as a Cake Tool

MesAuth.Authorizer

Enterprise-grade Authentication & Authorization middleware for MES Vietnam Fully supports .NET 8 · .NET 9 · .NET 10 · JWT · Key Rotation · Refresh Token · Permission-based · Multi-tenant

NuGet Version NuGet Downloads Build Status License: MIT

Table of Contents

⚠️ Breaking Changes

Version 10.4.0

  • JWKS format changed: /.well-known/jwks.json now returns a JWKS Set { "keys": [...] } array instead of a single JsonWebKey object. DiscoveryConfig.JsonWebKey is replaced by DiscoveryConfig.SigningKeys (IList<SecurityKey>).
  • Multi-key validation: IssuerSigningKeyResolver is used instead of a static IssuerSigningKey. All active + grace-period keys are accepted simultaneously.
  • JWKS cache TTL reduced: Discovery cache drops from 24 hours → 5 minutes to detect key rotation quickly.
  • Auto-retry on key rotation: OnAuthenticationFailed automatically calls DiscoveryService.RefreshAsync() and retries validation when a SecurityTokenSignatureKeyNotFoundException is raised — zero downtime during rotation.

Version 10.3.0

  • SSL trust helper extracted: Multi-domain certificate trust now uses MesAuth.SslTrustHelper (AddTrustedDomains(params string[])) instead of inline config.

Version 10.2.2

  • Removed gRPC dependencies: The package no longer requires gRPC communication. All authentication and authorization now works through HTTP APIs only.
  • Simplified architecture: Reduced complexity by removing gRPC client/server components.

Features

  • JWT Bearer authentication (RFC 7519 compliant)
  • Refresh token with rotation & reuse detection
  • Permission-based, Role-based, Policy-based, Claim-based & Tenant-based authorization
  • Redis distributed revocation list & refresh token storage
  • Multi-tenancy ready (TenantId claim)
  • Built-in logging, metrics (Prometheus) and OpenTelemetry tracing
  • Fully async & high performance
  • HTTP-only communication (no gRPC dependencies)

Updates

  • 10.4.0 BREAKING CHANGE: JWT key rotation support. JWKS endpoint now returns { "keys": [...] } array; DiscoveryConfig.SigningKeys replaces JsonWebKey; IssuerSigningKeyResolver handles multi-key validation; OnAuthenticationFailed auto-refreshes JWKS and retries on SecurityTokenSignatureKeyNotFoundException. JWKS cache reduced to 5 minutes.
  • 10.3.0 BREAKING CHANGE: SSL certificate trust refactored into MesAuth.SslTrustHelper with multi-domain support via AddTrustedDomains(params string[]).
  • 10.2.2 BREAKING CHANGE: Removed gRPC dependencies and communication. Enhanced HttpContext logging extensions (LogInfo/LogError) for centralized audit logging, improved middleware ordering documentation, and streamlined IUser interface
  • 10.1.1 Added support for roles in JWT tokens - user roles are now included in tokens and accessible via IUser.Roles
  • 10.1.0 Enhanced SSL certificate validation, improved refresh token coordination with automatic cleanup, added configurable gRPC timeout, optimized service registrations, reduced JWT clock skew for better security, and streamlined IUser record
  • 10.0.31 Enhanced user profile with HR information support and avatar upload functionality
  • 10.0.30 Performance improvements and code refactoring

Installation

# .NET 8+
dotnet add package MesAuth.Authorizer

Quick Start

Basic Setup

builder.Services.AddMesAuth(options =>
{
    options.AppId = "your-app-id";
    options.AppKey = "your-app-key";
    options.WellknowConfigUri = "https://your-auth-server/.well-known/openid-configuration";
    options.AutoRegisterEndpoints = false; // Set to true to auto-register auth endpoints
});

// In your middleware pipeline
app.UseMesAuth();

Exception Handling

For routes that should bypass authentication (like error pages):

app.MapGet("/", () => Results.Ok(new { message = "This is exception page" }))
    .MesAuthException();

Authorization Examples

Permission-Based Access

// Check permissions in your endpoints
app.MapGet("/api/data", async (HttpContext context) =>
{
    var user = context.GetUser();
    if (user?.Perms?.Contains("read:data") != true)
        return Results.Forbid();

    return Results.Ok("Authorized data");
});

User Information

// Get current user information
var user = context.GetUser();
if (user != null)
{
    var userId = user.UserId;
    var fullName = user.FullName;
    var permissions = user.Perms;
}

Notification Service

// Inject the notification service
private readonly ClientNotificationService _notificationService;

public MyController(ClientNotificationService notificationService)
{
    _notificationService = notificationService;
}

// Send notifications
await _notificationService.SendNotificationAsync(userId, "Your message here");

Centralized Logging

// Use HttpContext extensions for centralized audit logging
await context.LogInfo(ClientLogCategory.SystemEvent, "User uploaded file: {fileName}", fileName);
await context.LogError(ClientLogCategory.Security, "Failed login attempt for user: {userName}", userName);

// Available categories:
// - ClientLogCategory.SystemEvent
// - ClientLogCategory.Authorization  
// - ClientLogCategory.Authentication
// - ClientLogCategory.Security

Requirements

  • .NET 8.0 or higher
  • ASP.NET Core
  • Redis (for distributed token storage)
  • Valid MesAuth service configuration

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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 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.

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
10.5.0 80 3/3/2026
10.4.6 79 3/3/2026
10.4.5 80 3/2/2026
10.4.4 101 2/20/2026
10.4.3 94 2/20/2026
10.4.2 94 2/20/2026
10.4.1 98 2/20/2026
10.4.0 94 2/20/2026
10.2.4 93 2/12/2026
10.2.3 101 2/3/2026
10.2.2 113 1/28/2026
10.2.1 113 1/26/2026
10.2.0 97 1/24/2026
10.1.9 107 1/22/2026
10.1.8 98 1/21/2026
10.1.7 102 1/21/2026
10.1.6 92 1/21/2026
10.1.5 92 1/21/2026
10.1.4 97 1/21/2026
10.1.3 94 1/21/2026
Loading failed