MrWho.ClientAuth
1.5.0
dotnet add package MrWho.ClientAuth --version 1.5.0
NuGet\Install-Package MrWho.ClientAuth -Version 1.5.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="MrWho.ClientAuth" Version="1.5.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MrWho.ClientAuth" Version="1.5.0" />
<PackageReference Include="MrWho.ClientAuth" />
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 MrWho.ClientAuth --version 1.5.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MrWho.ClientAuth, 1.5.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 MrWho.ClientAuth@1.5.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=MrWho.ClientAuth&version=1.5.0
#tool nuget:?package=MrWho.ClientAuth&version=1.5.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
MrWho.ClientAuth
A lightweight client-side configuration package to connect ASP.NET Core apps to the MrWho OpenID Connect identity server.
Quick start
- Add the package reference.
Program.cs:
builder.Services.AddMrWhoAuthentication(options =>
{
options.Authority = "https://localhost:7113"; // public URL of MrWho
options.ClientId = "my_app_client";
options.ClientSecret = "optional-secret"; // for confidential clients
// add API scopes if needed
options.Scopes.Add("api.read");
});
builder.Services.AddAuthorization();
- Map convenience login/logout endpoints (optional):
app.MapMrWhoLoginEndpoint();
app.MapMrWhoLogoutEndpoints();
app.MapMrWhoBackChannelLogoutEndpoint();
- Protect pages/controllers with
[Authorize].
Machine-to-Machine (client_credentials) helpers
Add an HttpClient that transparently acquires and caches a client_credentials token:
builder.Services.AddMrWhoClientCredentialsApi(
name: "DemoApiM2M",
baseAddress: new Uri("https://localhost:7162"),
configure: opt =>
{
opt.Authority = "https://localhost:7113";
opt.ClientId = "mrwho_demo_api_client";
opt.ClientSecret = "DemoApiClientSecret2025!";
opt.Scopes = new[] { "api.read" }; // optional
opt.AcceptAnyServerCertificate = builder.Environment.IsDevelopment();
});
Usage:
var client = httpClientFactory.CreateClient("DemoApiM2M");
var resp = await client.GetAsync("WeatherForecast");
Delegated user access token forwarding
Forward the signed-in user's access token to an API:
builder.Services.AddMrWhoUserAccessTokenApi(
name: "DemoApiUser",
baseAddress: new Uri("https://localhost:7162"));
Usage in page/controller:
var api = httpClientFactory.CreateClient("DemoApiUser");
var resp = await api.GetAsync("WeatherForecast");
Typed client variants are also available:
builder.Services.AddMrWhoClientCredentialsApi<MyApiClient>(new Uri("https://localhost:7162"), opt => { /* ... */ });
builder.Services.AddMrWhoUserAccessTokenApi<MyUserApiClient>(new Uri("https://localhost:7162"));
Notes and defaults
- Cookie + OIDC scheme naming isolated per ClientId.
- Saves tokens by default (access/id/refresh) when supported.
- Default scopes: openid, profile, email, roles, offline_access. Add api.read/api.write explicitly.
- Discovery path always:
/.well-known/openid-configuration. - M2M provider caches token until ~30s before expiry (configurable via RefreshSkew).
- Optional
AcceptAnyServerCertificatefor dev self-signed certs.
Security considerations
- Never enable
AcceptAnyServerCertificateoutside development. - Store client secrets securely (user-secrets, KeyVault, environment). Do not commit to source control.
- Limit scopes to the minimum required (principle of least privilege).
Back-channel logout
Map app.MapMrWhoBackChannelLogoutEndpoint(); in apps that must honor session revocation.
License: MIT
| 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 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.
-
net9.0
- Microsoft.AspNetCore.Authentication.OpenIdConnect (>= 9.0.9)
- Microsoft.IdentityModel.Protocols.OpenIdConnect (>= 8.14.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.