Pacem.IdentityModel 0.10.11

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

Pacem.IdentityModel

Shared OAuth 2.0 / OpenID Connect protocol vocabulary for Pacem.Id — the wire-format types (constants, request/response DTOs, protocol exceptions, the IdToken/JwtToken/UserInfoResponse claims models) plus a small set of typed HTTP clients, so that both the identity provider itself and any relying party written in C# share one vocabulary instead of each hand-rolling it.

What's in here

  • Protocol constantsKnownGrantTypes, KnownResponseTypes, KnownOidcScopes, KnownClientAuthenticationMethods, and the parameter-name constants for each request kind (KnownTokenRequestParameters, KnownAuthenticationRequestParameters, etc.).
  • Request/response DTOsAuthenticationRequest, TokenRequest/TokenResponse, IntrospectionRequest/IntrospectionResponse, RevocationRequest, DiscoveryDocument, PublicJwk/PublicJwkSet, Claim.
  • Protocol exceptionsOAuthException and its four subtypes (AuthenticationRequestException, TokenRequestException, IntrospectionRequestException, RevocationRequestException), each mapping to a standard OAuth error code.
  • Claims modelsJwtToken/IJwtToken, a lightweight typed wrapper over a JWT claims dictionary; the abstract IdToken (readonly claim accessors per the ID Token spec — built by IdTokenBuilder server-side, in Pacem.Id); and UserInfoResponse, the same shape for the UserInfo response.

Typed clients

AddPacemIdentityModelClient() registers IClientFactory — every client, IDiscoveryClient included, is obtained from it:

services.AddPacemIdentityModelClient();

Every client is built around ClientOptions.DiscoveryDocumentUrl — the full url of an OpenID Connect discovery document — so the same IClientFactory works against any spec-compliant OIDC provider, not just Pacem.Id. ClientOptions offers three ways to get one, from most to least Pacem.Id-specific:

  • ClientOptions.FromAuthorityAndTenant(authority, tenantId) — Pacem.Id is multi-tenant, and a single consuming service may well need to talk to several tenants (or several authorities) over its lifetime, each with its own credentials; this derives the url from that pair.
  • ClientOptions.FromIssuerUrl(issuerUrl) — derives the url from a bare issuer per the OIDC Discovery convention ({issuerUrl}/.well-known/openid-configuration), for any other spec-compliant provider.
  • new ClientOptions(discoveryDocumentUrl) — takes the exact url verbatim, for a provider whose discovery document isn't at the derivable location, or when you already have it (e.g. from configuration).
IClientFactory factory = provider.GetRequiredService<IClientFactory>();

// Pacem.Id: authority + tenant
ClientOptions discovery = ClientOptions.FromAuthorityAndTenant("https://id.pacem.it", "acme");
// any other OIDC provider, from its bare issuer:
// ClientOptions discovery = ClientOptions.FromIssuerUrl("https://accounts.example.com");
// or the exact discovery url, verbatim:
// ClientOptions discovery = new("https://accounts.example.com/.well-known/openid-configuration");

ITokenClient tokenClient = factory.CreateTokenClient(new ClientAuthenticationOptions(discovery)
{
    ClientId = "my-client",
    ClientSecret = "...",
});

TokenResponse tokens = await tokenClient.RequestTokenAsync(new TokenRequest
{
    GrantType = KnownGrantTypes.AuthorizationCode,
    Code = code,
    RedirectUri = redirectUri,
});

Each factory method takes the narrowest options type that client actually needs, rather than one type carrying every client's properties:

  • CreateDiscoveryClient — plain ClientOptions (discovery url only). Every other method already resolves the endpoint it needs through one of these internally; call this directly only when you want the discovery document itself, or to force a refetch via IDiscoveryClient.Refresh().
  • CreateUserInfoClient — plain ClientOptions (discovery url only; UserInfo authenticates with the bearer access token itself, no separate credential).
  • CreateTokenClient / CreateRevocationClientClientAuthenticationOptions (adds ClientId/ ClientSecret/ClientAuthenticationMethod; both authenticate as an OAuth client).
  • CreateIntrospectionClientIntrospectionClientOptions (adds ApiName/ApiSecret; introspection authenticates as an API resource, not as a client).

None of the endpoint URLs are hardcoded beyond that: every client resolves the endpoint it calls from its provider's discovery document, whose own well-known location is the only route that's ever assumed — the one spec-fixed constant. IDiscoveryClient itself is deliberately simple — fetch this one url once, cache forever, no TTL of its own — because IClientFactory is what actually owns the cache: one IDiscoveryClient per distinct discovery url, shared by every client created for that url (CreateTokenClient, CreateUserInfoClient, ... all resolve through the same cached instance), kept until discoveryCacheDuration elapses (default 24h, set once via AddPacemIdentityModelClient(discoveryCacheDuration: ...)) and then regenerated on next use. Calling IDiscoveryClient.Refresh() forces that one instance to re-fetch on its next call and tells the factory to drop it early, so a caller who forces a refresh doesn't leave a stale entry behind for everyone else sharing that url.

Notes

  • Targets net10.0 only; the request DTOs carry Microsoft.AspNetCore.Mvc-style binding attributes ([FromQuery]/[FromForm]) since Pacem.Id binds incoming requests to these same types server-side — they're inert metadata for outbound client use.
  • This library is C#-only by design: it's meant to be referenced directly by .NET relying parties and by Pacem.Id itself, not to describe a wire format for other languages.

References

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Pacem.IdentityModel:

Package Downloads
Pacem.Mvc.Extensions

Extensibility utilities for AspNet.Core web applications in Pacem Ecosystem.

Pacem.Identity.Infrastructure

Core components and extensions for an Identity Provider implementation in Pacem Ecosystem.

Pacem.Id

Pacem ID Provider, OpenID Connect compliant.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.10.11 76 8/28/2026
0.7.0-atlantis 625 10/1/2020 0.7.0-atlantis is deprecated because it is no longer maintained.
0.6.0 2,042 4/12/2020 0.6.0 is deprecated because it is no longer maintained.
0.5.4 1,512 8/29/2019
0.5.3 1,704 12/4/2018
0.5.2 1,652 11/30/2018
0.5.1 1,659 11/27/2018
0.5.0 1,685 11/21/2018
0.4.1 1,721 11/2/2018
0.4.0 1,762 10/22/2018