Tharga.Team.Service
2.0.16
dotnet add package Tharga.Team.Service --version 2.0.16
NuGet\Install-Package Tharga.Team.Service -Version 2.0.16
<PackageReference Include="Tharga.Team.Service" Version="2.0.16" />
<PackageVersion Include="Tharga.Team.Service" Version="2.0.16" />
<PackageReference Include="Tharga.Team.Service" />
paket add Tharga.Team.Service --version 2.0.16
#r "nuget: Tharga.Team.Service, 2.0.16"
#:package Tharga.Team.Service@2.0.16
#addin nuget:?package=Tharga.Team.Service&version=2.0.16
#tool nuget:?package=Tharga.Team.Service&version=2.0.16
Tharga Team Service
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-KEYheader, validates against a store, and populatesTeamKey,AccessLevel, and scope claims. - Access level authorization -
AccessLevelProxy<T>enforces[RequireAccessLevel]on service methods viaDispatchProxy. - 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
ApiKeyAdministrationServicewith key hashing. - Audit logging -
CompositeAuditLoggerwith 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();
System API keys
For infrastructure-level credentials that aren't tied to a team (MCP gatekeepers, CI/CD callers, cross-team admin tooling), use system keys — API keys with no TeamKey.
Create and manage them via the <SystemApiKeyView /> component in Tharga.Team.Blazor (gated by the Developer role), or programmatically via IApiKeyAdministrationService.CreateSystemKeyAsync(name, scopes, expiryDate, createdBy).
System keys authenticate through the same X-API-KEY header. The principal they produce carries the IsSystemKey=true claim and the explicit scopes granted at creation time — no TeamKey claim.
Protect system-only endpoints with the system policy:
app.MapMcp().RequireAuthorization(ApiKeyConstants.SystemPolicyName);
The two policies are mutually exclusive: ApiKeyPolicy rejects system keys, SystemApiKeyPolicy rejects team keys.
Team API keys
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
- Tharga.Team - Domain models, authorization primitives, and service abstractions.
- Tharga.MongoDB - MongoDB repository infrastructure.
- Tharga.Toolkit - Shared utilities including API key hashing.
- Swashbuckle.AspNetCore - Swagger UI generation.
Related packages
| 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 |
Links
| Product | Versions 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. |
-
net10.0
- Microsoft.AspNetCore.OpenApi (>= 10.0.7)
- Swashbuckle.AspNetCore (>= 10.1.7)
- Tharga.MongoDB (>= 2.10.9)
- Tharga.Team (>= 2.0.16)
-
net9.0
- Microsoft.AspNetCore.OpenApi (>= 9.0.15)
- Swashbuckle.AspNetCore (>= 10.1.7)
- Tharga.MongoDB (>= 2.10.9)
- Tharga.Team (>= 2.0.16)
NuGet packages (2)
Showing the top 2 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. |
|
|
Tharga.Platform.Mcp
Platform bridge for Tharga.Mcp. Provides Platform-backed IMcpContext, scope enforcement, audit logging, and authentication for MCP tool and resource invocations. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.16 | 0 | 5/7/2026 |
| 2.0.15 | 131 | 4/29/2026 |
| 2.0.14 | 117 | 4/29/2026 |
| 2.0.13 | 126 | 4/21/2026 |
| 2.0.12 | 114 | 4/20/2026 |
| 2.0.11 | 142 | 4/18/2026 |
| 2.0.10 | 113 | 4/17/2026 |
| 2.0.9 | 100 | 4/17/2026 |
| 2.0.8 | 139 | 4/8/2026 |
| 2.0.7 | 120 | 4/6/2026 |
| 2.0.5 | 109 | 4/5/2026 |
| 2.0.4 | 114 | 4/4/2026 |
| 2.0.3 | 119 | 4/3/2026 |
| 2.0.3-pre.1 | 53 | 4/3/2026 |
| 2.0.2 | 111 | 3/25/2026 |
| 2.0.2-pre.1 | 53 | 3/25/2026 |
| 2.0.1 | 65 | 3/24/2026 |
| 2.0.1-pre.5 | 56 | 3/24/2026 |
| 2.0.1-pre.4 | 52 | 3/24/2026 |
| 2.0.1-pre.3 | 55 | 3/23/2026 |