Purlin.CentralAuth.Provider
1.0.7
Prefix Reserved
dotnet add package Purlin.CentralAuth.Provider --version 1.0.7
NuGet\Install-Package Purlin.CentralAuth.Provider -Version 1.0.7
<PackageReference Include="Purlin.CentralAuth.Provider" Version="1.0.7" />
<PackageVersion Include="Purlin.CentralAuth.Provider" Version="1.0.7" />
<PackageReference Include="Purlin.CentralAuth.Provider" />
paket add Purlin.CentralAuth.Provider --version 1.0.7
#r "nuget: Purlin.CentralAuth.Provider, 1.0.7"
#:package Purlin.CentralAuth.Provider@1.0.7
#addin nuget:?package=Purlin.CentralAuth.Provider&version=1.0.7
#tool nuget:?package=Purlin.CentralAuth.Provider&version=1.0.7
Purlin.CentralAuth.Provider
Purlin.CentralAuth.Provider provides a lightweight and extensible way to interact with a Central Auth Provider API using a familiar Refit-like experience. It includes built-in token acquisition and caching mechanisms to improve performance and reduce redundant authentication requests.
π Features
- Refit-like interface for making API requests
- Built-in token acquisition using client credentials
- Token caching strategies:
- None β always requests a new token
- MemoryCache β stores token in local memory
- Redis β stores token in a shared Redis instance (ideal for distributed systems)
π¦ Installation
dotnet add package Purlin.CentralAuth.Provider
π οΈ Configuration
Start by defining your authentication and caching settings:
var providerUrl = "https://auth-provider.identity.com";
var authSettings = new AuthSettings
{
Authority = "https://auth.identity.com",
ClientId = "client_id",
ClientSecret = "client_secret",
TokenCachingMethod = TokenCacheMethodEnum.Redis, // Choose None, MemoryCache, or Redis
RedisSettings = new RedisSettings
{
Endpoint = "redis_endpoint",
Password = "redis_password",
Database = 0
}
};
builder.Services.AddCentralAuthProviderServices(authSettings, providerAPIBaseUrl);
Below are the available caching method descriptions:
- None β You will need to handle all token-related operations manually through a custom DelegatingHandler.
- MemoryCache β Ideal for systems not running behind load balancers. If using a load balancer, avoid this option to prevent inconsistent caching.
- Redis β Recommended for load-balanced environments. Tokens are stored in a centralized Redis instance and shared across service instances. Note: When TokenCachingMethod is set to Redis, the RedisSettings section is required.
The Redis instance used wonβt interfere with any existing Redis registrations. It is registered as a keyed singleton using an internal key known only to the package.
This package also allows you to configure a global timeout for all outgoing requests. By default, each request will timeout after 10 seconds, but you can customize this value if needed.
π Pagination Notes
All endpoints that support pagination use the following query parameters: page β the current page number (starting at 1, not 0) pageSize β the number of items to return per page
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. 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. |
-
net8.0
- Microsoft.Extensions.Caching.Memory (>= 9.0.6)
- Purlin.CentralAuth.Provider.Models (>= 1.0.5)
- Refit.HttpClientFactory (>= 7.0.0)
- StackExchange.Redis (>= 2.8.37)
-
net9.0
- Microsoft.Extensions.Caching.Memory (>= 9.0.6)
- Purlin.CentralAuth.Provider.Models (>= 1.0.5)
- Refit.HttpClientFactory (>= 7.0.0)
- StackExchange.Redis (>= 2.8.37)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.