Pavas.Runtime.IdentityContext 1.0.0

dotnet add package Pavas.Runtime.IdentityContext --version 1.0.0                
NuGet\Install-Package Pavas.Runtime.IdentityContext -Version 1.0.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="Pavas.Runtime.IdentityContext" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Pavas.Runtime.IdentityContext --version 1.0.0                
#r "nuget: Pavas.Runtime.IdentityContext, 1.0.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.
// Install Pavas.Runtime.IdentityContext as a Cake Addin
#addin nuget:?package=Pavas.Runtime.IdentityContext&version=1.0.0

// Install Pavas.Runtime.IdentityContext as a Cake Tool
#tool nuget:?package=Pavas.Runtime.IdentityContext&version=1.0.0                

Pavas.Runtime.IdentityContext

Pavas.Runtime.IdentityContext is a library designed to manage user identity, including authentication and authorization, within ASP.NET Core applications. It centralizes user-related information such as roles, claims, and other identity data, making it easier to access and manage across the application.

Features

  • Centralized Identity Management: Provides an IdentityContext class to encapsulate user identity information.
  • Middleware Support: Easily integrate identity management into the request pipeline using the IdentityContextMiddleware.
  • Claims and Roles Handling: Simplifies the handling of user claims, roles, and other identity attributes.

Installation

To use this library, include it in your project through dependency injection.

Usage

Setting Up the Identity Context

  1. Define the identity context when create a jwt token:

    var identityContext = new IdentityContext
    {
        Identifier = "1234567890",
        Username = "John Doe",
        Email = "john.doe@example.com",
        Country = "US",
        Gender = "Male",
        PostalCode = "12345",
        AuthenticationType = "Custom",
        IsAuthenticated = true,
        IpAddress = "127.0.0.1",
        Roles = ["Admin", "User"],
        Claims = [new Claim("custom-claim-type", "custom-claim-value")]
    };
    
  2. Inject the context into the service during application setup:

    builder.Services.AddIdentityContext();
    
  3. Add the middleware to the request pipeline:

    app.UseIdentityContextMiddleware();
    

License

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

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 135 8/25/2024