OrionLedger.AspNetCore 0.5.0

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

<p align="center"> <img src="https://raw.githubusercontent.com/tunahanaliozturk/OrionLedger/main/docs/logo.png" alt="OrionLedger" width="150" /> </p>

OrionLedger.AspNetCore

NuGet

ASP.NET Core authentication for OrionLedger. An authentication handler reads the API key from a configurable request header, verifies it through OrionLedger (hash lookup, revoked / expired / retired checks, and the last-used stamp), and on success establishes a ClaimsPrincipal carrying the key's subject, id, and scopes. Scopes are projected into claims so standard [Authorize(Policy = ...)] authorization gates an endpoint on a scope without the endpoint re-checking it.

dotnet add package OrionLedger.AspNetCore

Quick start

using Moongazing.OrionLedger;
using Moongazing.OrionLedger.AspNetCore;
using Moongazing.OrionLedger.AspNetCore.Authorization;

var builder = WebApplication.CreateBuilder(args);

// The key service the handler verifies against (in-memory store by default; swap in the
// EF Core store for persistence).
builder.Services.AddOrionLedger();

builder.Services
    .AddAuthentication(ApiKeyAuthenticationOptions.DefaultScheme)
    .AddOrionLedgerApiKey(options =>
    {
        options.HeaderName = "X-Api-Key"; // the default
    });

builder.Services.AddAuthorization(options =>
{
    // A named policy that requires the "orders:read" scope.
    options.AddApiKeyScopePolicy("orders:read", "orders:read");
});

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

app.MapGet("/orders", () => "ok")
   .RequireAuthorization("orders:read");

app.Run();

How it maps

  • The header value is used verbatim as the presented token (no Bearer prefix is stripped).
  • A Valid verification yields a principal with: the key id (orionledger:key-id by default), the subject as ClaimTypes.NameIdentifier and the identity name (when the key has a subject), and one scope claim per granted scope.
  • Any other status (revoked, expired, retired, unknown, malformed) fails authentication with no principal, so the request is unauthenticated and the framework returns 401.
  • A missing header produces NoResult, leaving other schemes and anonymous endpoints undisturbed.

Requiring scopes

Inline on an endpoint or in a named policy:

builder.Services.AddAuthorization(options =>
{
    // Any one of the listed scopes.
    options.AddPolicy("reporting", p => p.RequireApiKeyScope("reports:read", "reports:write"));

    // Require all listed scopes.
    options.AddPolicy("admin", p => p.RequireApiKeyScope(
        ApiKeyAuthenticationOptions.DefaultScopeClaimType, requireAll: true, "keys:admin", "keys:write"));
});

The claim type used for scopes, the subject, and the key id are all configurable on ApiKeyAuthenticationOptions.

See the project repository for the core key lifecycle API, the EF Core store, and the full design spec.

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
0.5.0 178 7/28/2026
0.4.0 137 7/20/2026