ArkaSoftware.Extensions.UsersManagement.Abstractions 2.0.0

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

ArkaSoftware.Extensions.UsersManagement.Abstractions

ArkaSoftware.Extensions.UsersManagement.Abstractions provides a flexible and testable interface for retrieving authenticated user information in .NET applications. It includes a full-featured interface and a fake implementation that can be used in test or development environments.


๐Ÿ”ง Interfaces

IUserInfoService

Defines methods for accessing user-related metadata from the current HTTP context or equivalent.

public interface IUserInfoService
{
    string GetUserAgent();
    string GetUserIp();
    string UserId();
    string GetFirstName();
}

๐Ÿงช FakeUserInfoService

A test-friendly implementation of IUserInfoService, ideal for development or unit testing.

public class FakeUserInfoService : IUserInfoService
{
    public FakeUserInfoService(string defaultUserId = "1") { ... }

    public string UserId() => "1";
    public string GetUsername() => "Username";
    public string GetFirstName() => "FirstName";
    public string GetLastName() => "LastName";
    public string GetUserAgent() => "1";
    public string GetUserIp() => "0.0.0.0";
    public string? GetClaim(string claimType) => claimType;
    public bool IsCurrentUser(string userId) => true;
    public string UserIdOrDefault() => _defaultUserId;
    public string UserIdOrDefault(string defaultValue) => defaultValue;
}


โœ… Use Cases

  • Accessing the current user's ID, IP, name, or claims

  • Supporting multi-tenant systems or audit logging

  • Unit testing services that depend on user context

  • Using fake implementations in background jobs or CLI tools


๐Ÿ“ฆ Benefits

  • โœ… Clean abstraction decouples your logic from HttpContext or security frameworks

  • ๐Ÿงช Fake implementation for test environments

  • ๐Ÿงฉ Easy to plug into DI containers and use anywhere in your codebase


๐Ÿงช Example: Inject into Services

public class AuditLogger
{
    private readonly IUserInfoService _userInfo;

    public AuditLogger(IUserInfoService userInfo)
    {
        _userInfo = userInfo;
    }

    public void Log(string message)
    {
        Console.WriteLine($"{_userInfo.UserId()} - {message}");
    }
}


๐Ÿข Maintained by

ArkaSoftware
๐Ÿ“ง Email Us
๐ŸŒ Web Site Visit

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

    • No dependencies.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on ArkaSoftware.Extensions.UsersManagement.Abstractions:

Package Downloads
ArkaSoftware.Extensions.UsersManagement

For Translation English Error To Farsi

Arks.Framework.Infra.Data.MSSQL.Command

Infrastructure library for MSSQL command handling using Entity Framework Core. Provides base classes, extensions, interceptors, and value converters for efficient database interactions.

Arks.Framework.Utilities.OutService

A multi-purpose library for .NET developers, including utilities for working with Persian dates, strings, and unique ID generation.

ArkaSoftware.Utilities.SeriLogRegisteration

SeriLog Registration Library For Use ASP.Net Core

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 271 4/16/2025
1.0.0 427 4/16/2024