Centeva.PrincipalProvider
1.0.1
Prefix Reserved
See the version list below for details.
dotnet add package Centeva.PrincipalProvider --version 1.0.1
NuGet\Install-Package Centeva.PrincipalProvider -Version 1.0.1
<PackageReference Include="Centeva.PrincipalProvider" Version="1.0.1" />
<PackageVersion Include="Centeva.PrincipalProvider" Version="1.0.1" />
<PackageReference Include="Centeva.PrincipalProvider" />
paket add Centeva.PrincipalProvider --version 1.0.1
#r "nuget: Centeva.PrincipalProvider, 1.0.1"
#:package Centeva.PrincipalProvider@1.0.1
#addin nuget:?package=Centeva.PrincipalProvider&version=1.0.1
#tool nuget:?package=Centeva.PrincipalProvider&version=1.0.1
Centeva.PrincipalProvider
Provides abstractions and implementations for user principal management in .NET applications, including support for web and background task scenarios.
Installation
Add the NuGet package to your project:
dotnet add package Centeva.PrincipalProvider
Or via the NuGet Package Manager in Visual Studio:
- Open the NuGet Package Manager
- Search for
Centeva.PrincipalProvider - Click Install
Usage
1. Register Services
Reference the registration pattern from your ServiceConfiguration.cs:
services.AddHttpContextAccessor();
services.AddSingleton<TaskRunnerPrincipalProvider>(sp =>
new TaskRunnerPrincipalProvider(
"your-authorization-key",
"TaskRunnerUser" // Default user for background tasks; can be customized
)
);
services.AddScoped<IPrincipalProvider, WebPrincipalProvider>();
services.AddScoped(sc => sc.GetService<IPrincipalProvider>()?.UserPrincipal ?? new ClaimsPrincipal());
2. Accessing the Principal
Inject IPrincipalProvider where needed:
public class MyService
{
private readonly IPrincipalProvider _principalProvider;
public MyService(IPrincipalProvider principalProvider)
{
_principalProvider = principalProvider;
}
public void DoSomething()
{
var principal = _principalProvider.UserPrincipal;
// Use principal as needed
}
}
3. Background Tasks
For background jobs, use TaskRunnerPrincipalProvider:
var provider = new TaskRunnerPrincipalProvider("your-authorization-key", "TaskRunnerUser");
var principal = provider.UserPrincipal;
API
IPrincipalProvider: Interface for principal providers.AuthorizationKey: The authorization key for the user context.AuthorizedUserId: The unique user identifier.UserPrincipal: The security principal for the user.
WebPrincipalProvider: UsesIHttpContextAccessorto provide the current web user.TaskRunnerPrincipalProvider: Provides a principal for background tasks.
Target Framework
- .NET 8
- C# 12
License
Distributed under the MIT License.
| 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 was computed. 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.AspNetCore.Http.Abstractions (>= 2.3.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Centeva.PrincipalProvider:
| Package | Downloads |
|---|---|
|
Centeva.Hangfire.HangfireScheduler
Provides abstractions and base implementations for configuring, scheduling, and managing Hangfire background tasks in .NET 8+ applications. Includes support for dependency injection and customizable task registration for both web and background processing scenarios. |
GitHub repositories
This package is not used by any popular GitHub repositories.