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
<PackageReference Include="ArkaSoftware.Extensions.UsersManagement.Abstractions" Version="2.0.0" />
<PackageVersion Include="ArkaSoftware.Extensions.UsersManagement.Abstractions" Version="2.0.0" />
<PackageReference Include="ArkaSoftware.Extensions.UsersManagement.Abstractions" />
paket add ArkaSoftware.Extensions.UsersManagement.Abstractions --version 2.0.0
#r "nuget: ArkaSoftware.Extensions.UsersManagement.Abstractions, 2.0.0"
#:package ArkaSoftware.Extensions.UsersManagement.Abstractions@2.0.0
#addin nuget:?package=ArkaSoftware.Extensions.UsersManagement.Abstractions&version=2.0.0
#tool nuget:?package=ArkaSoftware.Extensions.UsersManagement.Abstractions&version=2.0.0
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 | Versions 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. |
-
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.