Asya.JwtManager
1.0.2-rc
dotnet add package Asya.JwtManager --version 1.0.2-rc
NuGet\Install-Package Asya.JwtManager -Version 1.0.2-rc
<PackageReference Include="Asya.JwtManager" Version="1.0.2-rc" />
paket add Asya.JwtManager --version 1.0.2-rc
#r "nuget: Asya.JwtManager, 1.0.2-rc"
// Install Asya.JwtManager as a Cake Addin
#addin nuget:?package=Asya.JwtManager&version=1.0.2-rc&prerelease
// Install Asya.JwtManager as a Cake Tool
#tool nuget:?package=Asya.JwtManager&version=1.0.2-rc&prerelease
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 net7.0 net7.0-android net7.0-ios net7.0-maccatalyst net7.0-macos net7.0-tvos net7.0-windows |
-
net5.0
- Asya.DependencyInjection (>= 1.0.0)
- Microsoft.Extensions.Configuration (>= 5.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 5.0.0)
- Microsoft.Extensions.DependencyInjection (>= 5.0.2)
- System.IdentityModel.Tokens.Jwt (>= 6.12.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Initializing of the JWT manager