Lyo.Authorization.AspNetCore 3.0.0

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

Lyo.Authorization.AspNetCore

Call AddLyoApiTokenAuthentication and then AddLyoGrantAuthorization. The grant policy provider forwards every name that does not start with grant|, including scope policies, role policies, the default policy, and the fallback policy. A second call is a no-op.

Features

  • [RequireGrant] and .RequireGrant () share one handler. Several attributes on one action are combined with AND.
  • Subject is lyo:user when that claim is set, otherwise sub. A grant stored only for sub does not match when lyo:user is a different value.
  • Anonymous is 401. Authenticated without a grant is 403. A store exception is 500. A missing or non-guid tenant route does not succeed and does not throw.
  • MapGrantEndpoints lists, saves, revokes, and checks grants for an already authenticated caller. Subject is lyo:user or else sub. Save, revoke, and another subject's list or check require authorization.grants.manage when the host passes that policy.

Examples

Controller and minimal API

[RequireScope("note.read")]
[RequireRole("editor")]
[RequireGrant("read", "note", resourceIdRoute: "id")]
[HttpGet("/notes/{id:guid}")]
public IActionResult GetNote(Guid id) => Ok();

group.MapGet("/notes/{id:guid}", GetNote)
    .RequireScope("note.read")
    .RequireRole("editor")
    .RequireGrant("read", "note", resourceIdRoute: "id");

app.MapGrantEndpoints(GrantEndpoints.ManagePolicyName);

Dependencies

Generated from ProjectReference / PackageReference (same model as docs/Lyo.ProjectGraph.html).

  • Lyo.Authorization (direct, lyo)
  • Lyo.Exceptions (direct, lyo)
  • Lyo.Audit (transitive, lyo)
  • Lyo.Common.Core (transitive, lyo)
  • Lyo.EntityReference.Models (transitive, lyo)
  • Lyo.Health (transitive, lyo)
  • Lyo.Metrics (transitive, lyo)
  • Microsoft.Bcl.AsyncInterfaces 10.0.5 (transitive, microsoft, netstandard2.0)
  • Microsoft.Extensions.DependencyInjection.Abstractions 10.0.5 (transitive, microsoft)
  • Microsoft.Extensions.Logging.Abstractions 10.0.5 (transitive, microsoft)
  • System.Memory 4.6.3 (transitive, microsoft, netstandard2.0)
  • System.Text.Json 10.0.5 (transitive, microsoft, netstandard2.0)
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
3.0.0 65 10/23/2026