Soenneker.Utils.UserContext 4.0.1773

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package Soenneker.Utils.UserContext --version 4.0.1773
                    
NuGet\Install-Package Soenneker.Utils.UserContext -Version 4.0.1773
                    
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="Soenneker.Utils.UserContext" Version="4.0.1773" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Utils.UserContext" Version="4.0.1773" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Utils.UserContext" />
                    
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 Soenneker.Utils.UserContext --version 4.0.1773
                    
#r "nuget: Soenneker.Utils.UserContext, 4.0.1773"
                    
#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 Soenneker.Utils.UserContext@4.0.1773
                    
#: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=Soenneker.Utils.UserContext&version=4.0.1773
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Utils.UserContext&version=4.0.1773
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image Soenneker.Utils.UserContext

A utility library for retrieving various user information from the request context.

Installation

dotnet add package Soenneker.Utils.UserContext

Quick start

using Soenneker.Utils.UserContext.Registrars;

services.AddUserContextAsScoped();

Then inject IUserContext wherever you need it.

Common operations

  • SetInternalContext() - Sets an internal context for system or service use.
  • SetApiKey() - Sets an API key override for the current context instance.
  • GetId() - Grabs the user id from the current context Throws an auth error if no user id is found.
  • GetIdSafe() - Grabs the user id from the current context. If it's not found it returns null.
  • GetEmail() - Retrieves the email address associated with the current instance. Returns a string containing the email address. The value may be empty if no email address is set.
  • GetJwt() - Grabs the JWT from the current context Throws an auth error if not found.
  • GetApiKey() - Grabs the header from the current request's context Returns null if the key is not present.
  • HasRoles() - Determines whether the current principal is assigned any of the specified roles.
  • HasRole() - Returns whether the current HTTP user's ClaimsPrincipal belongs to the requested role; returns false when no current user exists.
  • IsAdmin() - Shorthand for HasUserRole(Admin). Will NOT throw an exception.
  • IsNotAdmin() - Determines whether the current user does not have administrative privileges.
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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 (2)

Showing the top 2 NuGet packages that depend on Soenneker.Utils.UserContext:

Package Downloads
Soenneker.Cosmos.Repository

A data persistence abstraction layer for Cosmos DB

Soenneker.Managers.Base

An abstract class providing common functionality for managers

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.1782 0 8/31/2026
4.0.1781 0 8/30/2026
4.0.1780 0 8/30/2026
4.0.1779 0 8/30/2026
4.0.1778 42 8/30/2026
4.0.1776 70 8/30/2026
4.0.1775 51 8/29/2026
4.0.1774 41 8/29/2026
4.0.1773 92 8/29/2026
4.0.1772 76 8/29/2026
4.0.1771 365 8/26/2026
4.0.1770 212 8/25/2026
4.0.1769 511 8/21/2026
4.0.1768 881 8/18/2026
4.0.1767 85 8/18/2026
4.0.1766 712 8/12/2026
4.0.1765 794 8/8/2026
4.0.1764 497 8/7/2026
4.0.1763 666 7/29/2026
4.0.1762 433 7/28/2026
Loading failed

Improve XML documentation