HyperDev.IdentityModel
1.2.1
dotnet add package HyperDev.IdentityModel --version 1.2.1
NuGet\Install-Package HyperDev.IdentityModel -Version 1.2.1
<PackageReference Include="HyperDev.IdentityModel" Version="1.2.1" />
<PackageVersion Include="HyperDev.IdentityModel" Version="1.2.1" />
<PackageReference Include="HyperDev.IdentityModel" />
paket add HyperDev.IdentityModel --version 1.2.1
#r "nuget: HyperDev.IdentityModel, 1.2.1"
#:package HyperDev.IdentityModel@1.2.1
#addin nuget:?package=HyperDev.IdentityModel&version=1.2.1
#tool nuget:?package=HyperDev.IdentityModel&version=1.2.1
HyperDev.IdentityModel
JWT helpers built on System.IdentityModel.Tokens.Jwt, part of the HyperDev Fatum framework.
Reads bearer tokens from HTTP headers and turns them into a ClaimsPrincipal.
- Parsing of a JWT from a string, with or without the
Bearerprefix (base64 padding and+//characters are normalized) - Extensions on
IDictionary<string, StringValues>(for example ASP.NET Core request headers) to read the token or the identity from theAuthorizationheader or any other header - Claim lookup on a
JwtSecurityToken(case-insensitive claim type) and token serialization IClaimsPrincipalAccessorabstraction and an anonymous principal factory
The token is only read, not validated: signature, issuer, audience and lifetime are not checked.
Use these helpers where the token has already been validated, or validate it with JwtSecurityTokenHandler.ValidateToken.
Installation
dotnet add package HyperDev.IdentityModel
Quick start
using HyperDev.IdentityModel;
using Microsoft.Extensions.Primitives;
var headers = new Dictionary<string, StringValues>
{
["Authorization"] = "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI0MiJ9.c2lnbmF0dXJl"
};
if (headers.TryGetJwtToken(out var token) && token.TryGetClaim("sub", out var subject))
Console.WriteLine($"Subject: {subject}");
if (headers.TryGetJwtIdentity(out var principal))
Console.WriteLine(principal.Identity.AuthenticationType); // "jwt"
Target frameworks
.NET 8.0, .NET 10.0
License
MIT, © Ivan Senatore, Wemake Informatica srl. Third-party dependencies keep their own licenses (System.IdentityModel.Tokens.Jwt: MIT, Microsoft.Extensions.*: MIT).
| Product | Versions 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 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. |
-
net10.0
- HyperDev.Core (>= 1.2.4)
- System.IdentityModel.Tokens.Jwt (>= 8.21.0)
-
net8.0
- HyperDev.Core (>= 1.2.4)
- System.IdentityModel.Tokens.Jwt (>= 8.21.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on HyperDev.IdentityModel:
| Package | Downloads |
|---|---|
|
HyperDev.Web
HyperDev Fatum Framework |
GitHub repositories
This package is not used by any popular GitHub repositories.