Modgud.AspNetCore.ResourceServer 0.10.3

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

Modgud.AspNetCore.ResourceServer

ASP.NET Core integration for APIs protected by a Modgud identity provider.

The package has one registration method and one public authentication scheme. ModgudTokenMode controls whether the API accepts self-contained JWTs, opaque reference tokens, or both. In Both mode, the package routes three-part JWTs to local validation and opaque tokens to RFC 7662 introspection.

Both validation paths select resource_access[<audience>] and project its roles and permissions onto the authenticated identity. Roles use ClaimTypes.Role; permissions use ModgudClaimTypes.Permission.

Install

dotnet add package Modgud.AspNetCore.ResourceServer

JWT quickstart

JWT is the default mode:

using Modgud.AspNetCore.ResourceServer;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddModgudResourceServer(options =>
{
    options.Authority = "https://auth.example.com";
    options.Audience = "event-tree-api";
});

var app = builder.Build();
app.UseAuthentication();
app.UseAuthorization();

app.MapGet("/admin/ping", () => "pong")
    .RequireAuthorization(policy => policy.RequireRole("Editor"));

app.MapPost("/calendars/{id}", (string id) => Results.Ok())
    .RequireModgudPermission("calendar:write");

app.Run();

JWT mode makes no per-request call to Modgud. A token must contain the configured audience and its resource_access block. There is deliberately no UserInfo fallback.

Reference-token mode

builder.Services.AddModgudResourceServer(options =>
{
    options.Authority = "https://auth.example.com";
    options.Audience = "event-tree-api";
    options.TokenMode = ModgudTokenMode.OnlyReferenceToken;
    options.IntrospectionClientSecret =
        builder.Configuration["Modgud:IntrospectionSecret"];
});

The resource server authenticates to /connect/introspect with a confidential OAuth client. IntrospectionClientId defaults to Audience; in the usual setup the introspection client's ID therefore equals the resource-server audience. Validation is fail-closed and uncached, so revocation takes effect on the next request.

Accept both formats

builder.Services.AddModgudResourceServer(options =>
{
    options.Authority = "https://auth.example.com";
    options.Audience = "event-tree-api";
    options.TokenMode = ModgudTokenMode.Both;
    options.IntrospectionClientSecret =
        builder.Configuration["Modgud:IntrospectionSecret"];
});

The application still exposes one authentication scheme. Token shape only selects the internal validator; it never bypasses signature, issuer, audience, expiry, active-state, or DPoP validation. A second AddModgudResourceServer(...) call is rejected.

Permission gates

RequireModgudPermission adds normal ASP.NET Core authorization metadata. It works on both RouteHandlerBuilder and RouteGroupBuilder and yields 401 for anonymous callers or 403 for authenticated callers without the exact permission:

var writeApi = app.MapGroup("/write")
    .RequireModgudPermission("calendar:write");

Bypass grants such as realm:admin and <resource>:admin are expanded by the IdP before token issuance. The resource server performs only an exact claim check.

Claims

Given:

"resource_access": {
  "event-tree-api": {
    "roles": ["Editor"],
    "permissions": ["calendar:read", "calendar:write"]
  }
}

read the projected values with:

var roles = user.FindAll(ClaimTypes.Role).Select(claim => claim.Value);
var permissions = user.FindAll(ModgudClaimTypes.Permission)
    .Select(claim => claim.Value);

Configuration

Option Description
Authority Required realm host root.
Audience Required token audience and resource_access key.
TokenMode OnlyJwt (default), OnlyReferenceToken, or Both.
IntrospectionClientId Introspection client ID; defaults to Audience.
IntrospectionClientSecret Required when the mode accepts reference tokens.
RequireHttpsMetadata Requires an HTTPS authority; defaults to true.
ConfigureJwtBearer Optional advanced JWT bearer configuration in JWT-capable modes.

The valid option combination is checked immediately during registration. required properties cannot express the mode-dependent secret requirement, so invalid combinations fail with OptionsValidationException.

License

Apache-2.0. See LICENSE.

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

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.10.3 80 8/27/2026
0.10.2 84 8/26/2026
0.10.1 88 8/26/2026
0.10.0 88 8/26/2026
0.9.2 95 8/14/2026
0.9.1 90 8/14/2026
0.9.0 94 8/13/2026
0.8.0 109 8/1/2026