ApricotFramework.Authentication
0.1.0
Prefix Reserved
dotnet add package ApricotFramework.Authentication --version 0.1.0
NuGet\Install-Package ApricotFramework.Authentication -Version 0.1.0
<PackageReference Include="ApricotFramework.Authentication" Version="0.1.0" />
<PackageVersion Include="ApricotFramework.Authentication" Version="0.1.0" />
<PackageReference Include="ApricotFramework.Authentication" />
paket add ApricotFramework.Authentication --version 0.1.0
#r "nuget: ApricotFramework.Authentication, 0.1.0"
#:package ApricotFramework.Authentication@0.1.0
#addin nuget:?package=ApricotFramework.Authentication&version=0.1.0
#tool nuget:?package=ApricotFramework.Authentication&version=0.1.0
ApricotFramework.Authentication
Both directions of a microservice's authentication from one settings section: JWT bearer validation for the requests it serves, and OAuth 2.0 client credentials tokens for the services it calls — discovered, cached until shortly before they expire, and coalesced so a cold start makes one token request rather than one per caller.
ApricotFramework.Authentication is the zero-dependency core, and works in a console or worker host
without ASP.NET Core.
Install
dotnet add package ApricotFramework.Authentication.AspNetCore
dotnet add package ApricotFramework.Authentication.ErrorDefinitions # to answer with problem+json
Usage
// Inbound validation and the outbound client, from one section.
builder.Services.AddJwtBearerAuthentication(builder.Configuration);
builder.Services.AddAuthorization();
builder.Services.AddAuthenticationErrorDefinitions();
{
"Authentication": {
"Authority": "https://idp.example.com",
"ValidAudiences": [ "orders-api" ],
"Client": {
// The secret comes from the environment, as Authentication__Client__ClientSecret.
"ClientId": "orders-service",
"Scopes": [ "billing.read" ]
}
}
}
[HttpGet("{id}")]
[BearerAuthorize]
public async Task<Order> Get(string id, CancellationToken cancellationToken)
{
// Works for a person and for a service alike: Subject is null for a machine token, because a
// client credentials grant has no resource owner to name.
var caller = this.HttpContext.GetPrincipal();
return await this.authenticator.DoAuthenticatedAsync(
(token, ct) => this.billing.GetAsync(id, token, ct),
cancellationToken: cancellationToken);
}
Note. A token this service could not obtain for an onward call never answers 401 or 403. The caller presented a good credential; it is this service that could not present one of its own, so it answers 503 when waiting may help and 500 when it will not.
Full documentation at projectapricot.dev.
| Product | Versions 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. |
-
net10.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on ApricotFramework.Authentication:
| Package | Downloads |
|---|---|
|
ApricotFramework.Authentication.AspNetCore
ASP.NET Core integration for ApricotFramework.Authentication: JWT bearer validation configured from one settings section, a service-to-service client whose credentials come from the same section, and startup validation that rejects a resource server which could never accept a token. |
|
|
ApricotFramework.Grpc.Client.Authentication
Presents this service's own access token on outbound gRPC calls, obtained through ApricotFramework.Authentication, and reports a failure to obtain one as a fault of this service rather than of whoever called it. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0 | 142 | 8/19/2026 |