Tharga.Team.Service 2.0.0

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

Tharga Team Service

NuGet Nuget License

Server-side API-key authentication, authorization enforcement, controller registration, OpenAPI/Swagger setup, and audit logging for ASP.NET Core projects. Targets .NET 9.0 and .NET 10.0.

Features

  • API key authentication - Reads the X-API-KEY header, validates against a store, and populates TeamKey, AccessLevel, and scope claims.
  • Access level authorization - AccessLevelProxy<T> enforces [RequireAccessLevel] on service methods via DispatchProxy.
  • Scope authorization - ScopeProxy<T> enforces [RequireScope] with audit logging.
  • Controller + Swagger registration - Single-call setup for MVC controllers, OpenAPI document with API key security scheme, and Swagger UI.
  • API key management - Default MongoDB-backed ApiKeyAdministrationService with key hashing.
  • Audit logging - CompositeAuditLogger with ILogger and MongoDB storage backends.
  • Pluggable - Implement IApiKeyAdministrationService (from Tharga.Team) to bring your own storage backend.

Quick start

using Tharga.Team;
using Tharga.Team.Service;

// Program.cs
builder.Services.AddThargaControllers();
builder.Services.AddAuthentication()
    .AddThargaApiKeyAuthentication();
builder.Services.AddThargaApiKeys();

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

Protect endpoints with the built-in policy:

[Authorize(Policy = ApiKeyConstants.PolicyName)]
[ApiController]
[Route("api/[controller]")]
public class MyController : ControllerBase
{
    [HttpGet]
    public IActionResult Get()
    {
        var teamKey = User.FindFirst(TeamClaimTypes.TeamKey)?.Value;
        return Ok(new { teamKey });
    }
}

Enforce access levels on services:

public interface IMyService
{
    [RequireAccessLevel(AccessLevel.Viewer)]
    IAsyncEnumerable<Item> GetAsync();

    [RequireAccessLevel(AccessLevel.User)]
    Task<Item> AddAsync(string name);
}

// Program.cs
builder.Services.AddScopedWithAccessLevel<IMyService, MyService>();

Dependencies

Package Description
Tharga.Team Domain models and authorization primitives (plain .NET, WASM-safe)
Tharga.Team.Blazor Team-specific Blazor UI components
Tharga.Blazor Generic Blazor UI components
Tharga.Team.MongoDB MongoDB persistence for teams and users
Product Compatible and additional computed target framework versions.
.NET 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 (1)

Showing the top 1 NuGet packages that depend on Tharga.Team.Service:

Package Downloads
Tharga.Team.Blazor

Team management Blazor components for multi-tenant applications. Works with both Blazor Server and WebAssembly.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 29 3/19/2026
2.0.0-pre.5 30 3/19/2026
2.0.0-pre.4 30 3/19/2026
2.0.0-pre.3 37 3/18/2026
2.0.0-pre.2 28 3/18/2026
2.0.0-pre.1 41 3/17/2026