Centeva.PrincipalProvider 1.0.1

Prefix Reserved
There is a newer version of this package available.
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
                    
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="Centeva.PrincipalProvider" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Centeva.PrincipalProvider" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Centeva.PrincipalProvider" />
                    
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 Centeva.PrincipalProvider --version 1.0.1
                    
#r "nuget: Centeva.PrincipalProvider, 1.0.1"
                    
#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 Centeva.PrincipalProvider@1.0.1
                    
#: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=Centeva.PrincipalProvider&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Centeva.PrincipalProvider&version=1.0.1
                    
Install as a Cake Tool

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

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.

Version Downloads Last Updated
2.0.0 93 8/25/2026
1.0.1 598 11/18/2025
1.0.0 276 11/6/2025