Asya.JwtManager 1.0.0

.NET 5.0
There is a newer prerelease version of this package available.
See the version list below for details.
Install-Package Asya.JwtManager -Version 1.0.0
dotnet add package Asya.JwtManager --version 1.0.0
<PackageReference Include="Asya.JwtManager" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Asya.JwtManager --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Asya.JwtManager, 1.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Asya.JwtManager as a Cake Addin
#addin nuget:?package=Asya.JwtManager&version=1.0.0

// Install Asya.JwtManager as a Cake Tool
#tool nuget:?package=Asya.JwtManager&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Asya JWT Manager

a lightweight JWT authentication manager that's allow you to work with JWT token easily and safe

you can register the package on the startup class as following in Configure method call UseAsyaJwtServices(configuration); and you should pass the configuration instance on this function then you must adding the JWT settings in you appsettings.json file as following

Property Description Default Value
Secret the secret key for you token generator none
Issuer the token issuer none
Audience the token audience none
ValidateIssuer should manager validate issuer false
ValidateAudience should manager validate audience false
ValidateLifeTime the token validation life time in minutes none
ValidateIssuerSigningKey should token validate the issuer signing key false
AccessTokenExpiration the access token expiring life time in minutes none
RefreshTokenExpiration the refresh token expiring life time in minutes none
RemoveCachedRefreshTokensEvery the automation remover background process for expired tokens in minutes 1
ClockSkew the token manger ClockSkew value 1

then you have a strong interface with a bunch of ready to use functions as following

AuthenticationResult GenerateTokens(string email, Claim[] claims, DateTime now); AuthenticationResult Refresh(string refreshToken, string accessToken, DateTime now); void RemoveExpiredRefreshTokens(DateTime now); void RemoveRefreshTokenByUserName(string userName); (ClaimsPrincipal, JwtSecurityToken) DecodeJwtToken(string token);

the AuthenticationResult should return the following

Proeprty Type
AccessToken string
RefreshToken RefreshToken

and the RefreshToken

Proeprty Type
UserName string
TokenString string
ExpireAt datetime
Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
Compatible target framework(s)
Additional computed target framework(s)
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.2-rc 117 9/22/2021
1.0.1-rc 98 9/22/2021
1.0.0 245 9/20/2021

Initializing of the JWT manager