AnyTixAuth 1.2.0

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

AnyTixAuth

Secure-by-default JWT authentication and authorization for AnyTix ASP.NET Core resource APIs.

For local package creation, MVC examples, direct request testing, and the complete integration sequence, see the repository's docs/resource-api-jwt-validation.md.

The package validates access tokens locally with the AuthApi issuer's OpenID Connect metadata and public signing keys. It does not call the auth database for normal API requests and does not depend on the AuthApi assembly.

Profile PII is intentionally absent from newly issued access tokens. Frontend and mobile clients call AuthApi /auth/me; trusted resource APIs can opt into the service-authenticated profile client described below.

Install

dotnet add package AnyTixAuth

Configure

{
  "AnyTixAuth": {
    "MetadataAddress": "https://auth.example.com/.well-known/openid-configuration",
    "Issuer": "https://auth.example.com",
    "Audience": "ticketing-api",
    "RequireHttpsMetadata": true,
    "ClockSkewSeconds": 60
  }
}
using System.Security.Claims;
using AnyTixAuth;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddAnyTixAuth(
    builder.Configuration.GetSection(
        AnyTixAuthDefaults.ConfigurationSectionName));

var app = builder.Build();

app.UseAnyTixAuth();

app.MapGet("/health/live", () => Results.Ok())
    .ExcludeFromAnyTixAuth();

app.MapGet("/orders", (ClaimsPrincipal user) =>
    Results.Ok(new { UserId = user.FindFirst("sub")?.Value }));

app.MapGet("/me", (ClaimsPrincipal user) =>
    Results.Ok(user.GetAnyTixUserData()));

app.MapPost("/scanner/check-in", () => Results.NoContent())
    .RequireAuthorization(policy => policy.RequireRole("scanner", "admin"));

app.Run();

Read Validated User And Token Data

GetAnyTixUserData() returns typed user fields, roles, scopes, issuer, audiences, token ID, issued/not-before/expiry timestamps, and AllClaims, which preserves every validated payload claim and repeated value:

AnyTixUserData userData = User.GetAnyTixUserData();

string? userId = userData.UserId;
IReadOnlyList<string> roles = userData.Roles;
IReadOnlyDictionary<string, IReadOnlyList<string>> allClaims =
    userData.AllClaims;

Call it on protected endpoints. The method reads the authenticated ClaimsPrincipal; it does not decode arbitrary tokens, expose the authorization header, or replace endpoint authorization.

For newly issued tokens, profile properties such as email, phone, name, and preferred username are empty because those claims are no longer emitted.

Retrieve Current Profile Data

Configure one confidential OAuth client per trusted business API. Keep ClientSecret in environment-backed configuration or a secret manager.

{
  "AnyTixAuth": {
    "UserClient": {
      "BaseAddress": "https://auth.example.com",
      "RequireHttps": true,
      "TokenEndpoint": "/connect/token",
      "ClientId": "ticketing-api",
      "ClientSecret": "<deployment secret>",
      "Scope": "users.read",
      "RefreshBeforeExpirySeconds": 30
    }
  }
}
builder.Services.AddAnyTixUserClient(
    builder.Configuration.GetSection("AnyTixAuth:UserClient"));

app.MapGet("/profile", async (
    IAnyTixUserClient users,
    CancellationToken cancellationToken) =>
    Results.Ok(await users.GetCurrentUserAsync(cancellationToken)));

GetCurrentUserAsync() reads the validated current sub automatically. Use GetUserByIdAsync(userId) only in trusted server-side workflows. The SDK obtains and caches a short-lived service token through OAuth client credentials; it never forwards the end-user bearer token for profile lookup.

Set RequireHttps to false only for an explicitly configured local HTTP development environment.

All endpoints require a valid access token by default. Exclude only intentional public endpoints with ExcludeFromAnyTixAuth(), the standard AllowAnonymous() endpoint extension, or [AllowAnonymous] on MVC controller actions.

Role, scope, ownership, and other business authorization remain the responsibility of the consuming API.

The configured Audience must exactly match the AuthApi AUTH_AUDIENCE value. Clients call this resource API directly with Authorization: Bearer <access_token>; they do not send business requests through the auth proxy.

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 was computed.  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
1.2.0 119 7/28/2026
1.1.0 109 7/26/2026
1.0.0 159 7/25/2026